HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulehpack-0.38.2Haskell2010

Hpack

  • 7 types
  • 11 values
  • Packagehpack-0.38.2
  • Exports18
  • LanguageHaskell2010
  • LicenceMIT
  • SourceHpack.hs

NOTE: This module is exposed to allow integration of Hpack into other tools. It is not meant for general use by end users. The following caveats apply:

  • The API is undocumented, consult the source instead.

  • The exposed types and functions primarily serve Hpack's own needs, not that of a public API. Breaking changes can happen as Hpack evolves.

As an Hpack user you either want to use the hpack executable or a build tool that supports Hpack (e.g. stack or cabal2nix).

Version

1 declaration

Running Hpack

6 declarations

Options

11 declarations

This is used to format any ParseExceptions encountered during decoding of defaults.

Note that:

  1. This is not used to format ParseExceptions encountered during decoding of the main package.yaml. To customize this you have to set a custom decode function.

  2. Some of the constructors of ParseException are never produced by Hpack (e.g. AesonException as Hpack uses it's own mechanism to decode Values).

Example:

example :: IO (Either HpackError Result)
example = hpackResultWithError options
  where
    options :: Options
    options = setCustomYamlParseErrorFormat format defaultOptions

    format :: FilePath -> ParseException -> String
    format file err = file ++ ": " ++ displayException err

setCustomYamlParseErrorFormat :: (FilePath -> ParseException -> String) -> Options -> Options
setCustomYamlParseErrorFormat format = setDecode decode >>> setFormatYamlParseError format
  where
    decode :: FilePath -> IO (Either String ([String], Value))
    decode file = first (format file) <$> decodeYamlWithParseError file