hpack-0.38.0: A modern format for Haskell packages

Safe Haskell | None
Language | Haskell2010

Hpack

Contents

- Version
- Running Hpack
- Options

Synopsis

- version :: Version
- hpack :: Verbose -> Options -> IO ()
- hpackResult :: Options -> IO Result
- hpackResultWithError :: Options -> IO (Either HpackError Result)
- printResult :: Verbose -> Result -> IO ()
- data Result = Result {
  - resultWarnings :: [String]
  - resultCabalFile :: String
  - resultStatus :: Status
  }
- data Status
  - = Generated
  - | ExistingCabalFileWasModifiedManually
  - | AlreadyGeneratedByNewerHpack
  - | OutputUnchanged
- defaultOptions :: Options
- setProgramName :: ProgramName -> Options -> Options
- setTarget :: FilePath -> Options -> Options
- setDecode :: (FilePath -> IO (Either String ([String], Value))) -> Options -> Options
- setFormatYamlParseError :: (FilePath -> ParseException -> String) -> Options -> Options
- getOptions :: FilePath -> [String] -> IO (Maybe (Verbose, Options))
- data Verbose
  - = Verbose
  - | NoVerbose
- data Options = Options {
  - optionsDecodeOptions :: DecodeOptions
  - optionsForce :: Force
  - optionsGenerateHashStrategy :: GenerateHashStrategy
  - optionsToStdout :: Bool
  - optionsOutputStrategy :: OutputStrategy
  }
- data Force
  - = Force
  - | NoForce
- data GenerateHashStrategy
  - = ForceHash
  - | ForceNoHash
  - | PreferHash
  - | PreferNoHash
- data OutputStrategy
  - = CanonicalOutput
  - | MinimizeDiffs

# Documentation

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

version :: Version #

# Running Hpack

hpack :: Verbose -> Options -> IO () #

hpackResult :: Options -> IO Result #

hpackResultWithError :: Options -> IO (Either HpackError Result) #

printResult :: Verbose -> Result -> IO () #

data Result #

Constructors

Result |
Fields resultWarnings :: [String] resultCabalFile :: String resultStatus :: Status

#### Instances

Instances details

Show Result # |
Instance details Defined in Hpack Methods showsPrec :: Int -> Result -> ShowS # show :: Result -> String # showList :: [Result] -> ShowS #
Eq Result # |
Instance details Defined in Hpack Methods (==) :: Result -> Result -> Bool # (/=) :: Result -> Result -> Bool #

data Status #

Constructors

Generated |
ExistingCabalFileWasModifiedManually |
AlreadyGeneratedByNewerHpack |
OutputUnchanged |

#### Instances

Instances details

Show Status # |
Instance details Defined in Hpack Methods showsPrec :: Int -> Status -> ShowS # show :: Status -> String # showList :: [Status] -> ShowS #
Eq Status # |
Instance details Defined in Hpack Methods (==) :: Status -> Status -> Bool # (/=) :: Status -> Status -> Bool #

# Options

defaultOptions :: Options #

setProgramName :: ProgramName -> Options -> Options #

setTarget :: FilePath -> Options -> Options #

setDecode :: (FilePath -> IO (Either String ([String], Value))) -> Options -> Options #

setFormatYamlParseError :: (FilePath -> ParseException -> String) -> Options -> Options #

This is used to format any `ParseException`s encountered during decoding of defaults.

Note that:

1. This is not used to format `ParseException`s 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 `Value`s).

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

getOptions :: FilePath -> [String] -> IO (Maybe (Verbose, Options)) #

data Verbose #

Constructors

Verbose |
NoVerbose |

#### Instances

Instances details

Show Verbose # |
Instance details Defined in Hpack.Options Methods showsPrec :: Int -> Verbose -> ShowS # show :: Verbose -> String # showList :: [Verbose] -> ShowS #
Eq Verbose # |
Instance details Defined in Hpack.Options Methods (==) :: Verbose -> Verbose -> Bool # (/=) :: Verbose -> Verbose -> Bool #

data Options #

Constructors

Options |
Fields optionsDecodeOptions :: DecodeOptions optionsForce :: Force optionsGenerateHashStrategy :: GenerateHashStrategy optionsToStdout :: Bool optionsOutputStrategy :: OutputStrategy

data Force #

Constructors

Force |
NoForce |

#### Instances

Instances details

Show Force # |
Instance details Defined in Hpack.Options Methods showsPrec :: Int -> Force -> ShowS # show :: Force -> String # showList :: [Force] -> ShowS #
Eq Force # |
Instance details Defined in Hpack.Options Methods (==) :: Force -> Force -> Bool # (/=) :: Force -> Force -> Bool #

data GenerateHashStrategy #

Constructors

ForceHash |
ForceNoHash |
PreferHash |
PreferNoHash |

#### Instances

Instances details

Show GenerateHashStrategy # |
Instance details Defined in Hpack Methods showsPrec :: Int -> GenerateHashStrategy -> ShowS # show :: GenerateHashStrategy -> String # showList :: [GenerateHashStrategy] -> ShowS #
Eq GenerateHashStrategy # |
Instance details Defined in Hpack Methods (==) :: GenerateHashStrategy -> GenerateHashStrategy -> Bool # (/=) :: GenerateHashStrategy -> GenerateHashStrategy -> Bool #

data OutputStrategy #

Constructors

CanonicalOutput |
MinimizeDiffs |

#### Instances

Instances details

Show OutputStrategy # |
Instance details Defined in Hpack.Options Methods showsPrec :: Int -> OutputStrategy -> ShowS # show :: OutputStrategy -> String # showList :: [OutputStrategy] -> ShowS #
Eq OutputStrategy # |
Instance details Defined in Hpack.Options Methods (==) :: OutputStrategy -> OutputStrategy -> Bool # (/=) :: OutputStrategy -> OutputStrategy -> Bool #