stack-1.4.0: The Haskell Tool Stack

Safe Haskell | None
Language | Haskell2010

Stack.Package

Description

Dealing with Cabal.

Synopsis

- readPackage :: (MonadLogger m, MonadIO m, MonadCatch m) => PackageConfig -> Path Abs File -> m ([PWarning], Package)
- readPackageBS :: MonadThrow m => PackageConfig -> ByteString -> m ([PWarning], Package)
- readPackageDescriptionDir :: (MonadLogger m, MonadIO m, MonadCatch m) => PackageConfig -> Path Abs Dir -> m (GenericPackageDescription, PackageDescription)
- readDotBuildinfo :: MonadIO m => Path Abs File -> m HookedBuildInfo
- readPackageUnresolved :: (MonadIO m, MonadThrow m) => Path Abs File -> m ([PWarning], GenericPackageDescription)
- readPackageUnresolvedBS :: MonadThrow m => Maybe (Path Abs File) -> ByteString -> m ([PWarning], GenericPackageDescription)
- resolvePackage :: PackageConfig -> GenericPackageDescription -> Package
- packageFromPackageDescription :: PackageConfig -> GenericPackageDescription -> PackageDescription -> Package
- findOrGenerateCabalFile :: forall m. (MonadThrow m, MonadIO m, MonadLogger m) => Path Abs Dir -> m (Path Abs File)
- hpack :: (MonadIO m, MonadLogger m) => Path Abs Dir -> m ()
- data Package = Package {
  - packageName :: !PackageName
  - packageVersion :: !Version
  - packageLicense :: !License
  - packageFiles :: !GetPackageFiles
  - packageDeps :: !(Map PackageName VersionRange)
  - packageTools :: ![Dependency]
  - packageAllDeps :: !(Set PackageName)
  - packageGhcOptions :: ![Text]
  - packageFlags :: !(Map FlagName Bool)
  - packageDefaultFlags :: !(Map FlagName Bool)
  - packageHasLibrary :: !Bool
  - packageTests :: !(Map Text TestSuiteInterface)
  - packageBenchmarks :: !(Set Text)
  - packageExes :: !(Set Text)
  - packageOpts :: !GetPackageOpts
  - packageHasExposedModules :: !Bool
  - packageSimpleType :: !Bool
  - packageSetupDeps :: !(Maybe (Map PackageName VersionRange))
  }
- newtype GetPackageFiles = GetPackageFiles {
  - getPackageFiles :: forall m env. (StackM env m, HasEnvConfig env) => Path Abs File -> m (Map NamedComponent (Set ModuleName), Map NamedComponent (Set DotCabalPath), Set (Path Abs File), [PackageWarning])
  }
- newtype GetPackageOpts = GetPackageOpts {
  - getPackageOpts :: forall env m. (StackM env m, HasEnvConfig env) => SourceMap -> InstalledMap -> [PackageName] -> [PackageName] -> Path Abs File -> m (Map NamedComponent (Set ModuleName), Map NamedComponent (Set DotCabalPath), Map NamedComponent BuildInfoOpts)
  }
- data PackageConfig = PackageConfig {
  - packageConfigEnableTests :: !Bool
  - packageConfigEnableBenchmarks :: !Bool
  - packageConfigFlags :: !(Map FlagName Bool)
  - packageConfigGhcOptions :: ![Text]
  - packageConfigCompilerVersion :: !CompilerVersion
  - packageConfigPlatform :: !Platform
  }
- buildLogPath :: (MonadReader env m, HasBuildConfig env, MonadThrow m) => Package -> Maybe String -> m (Path Abs File)
- data PackageException
  - = PackageInvalidCabalFile (Maybe (Path Abs File)) PError
  - | PackageNoCabalFileFound (Path Abs Dir)
  - | PackageMultipleCabalFilesFound (Path Abs Dir) [Path Abs File]
  - | MismatchedCabalName (Path Abs File) PackageName
- resolvePackageDescription :: PackageConfig -> GenericPackageDescription -> PackageDescription
- packageToolDependencies :: PackageDescription -> Map Text VersionRange
- packageDependencies :: PackageDescription -> Map PackageName VersionRange
- autogenDir :: Path Abs Dir -> Path Abs Dir
- checkCabalFileName :: MonadThrow m => PackageName -> Path Abs File -> m ()
- printCabalFileWarning :: MonadLogger m => Path Abs File -> PWarning -> m ()
- cabalFilePackageId :: (MonadIO m, MonadThrow m) => Path Abs File -> m PackageIdentifier

# Documentation

readPackage :: (MonadLogger m, MonadIO m, MonadCatch m) => PackageConfig -> Path Abs File -> m ([PWarning], Package) #

Reads and exposes the package information

readPackageBS :: MonadThrow m => PackageConfig -> ByteString -> m ([PWarning], Package) #

Reads and exposes the package information, from a ByteString

readPackageDescriptionDir :: (MonadLogger m, MonadIO m, MonadCatch m) => PackageConfig -> Path Abs Dir -> m (GenericPackageDescription, PackageDescription) #

Get `GenericPackageDescription` and `PackageDescription` reading info from given directory.

readDotBuildinfo :: MonadIO m => Path Abs File -> m HookedBuildInfo #

Read `package.buildinfo` ancillary files produced by some Setup.hs hooks. The file includes Cabal file syntax to be merged into the package description derived from the package's .cabal file.

NOTE: not to be confused with BuildInfo, an Stack-internal datatype.

readPackageUnresolved :: (MonadIO m, MonadThrow m) => Path Abs File -> m ([PWarning], GenericPackageDescription) #

Read the raw, unresolved package information.

readPackageUnresolvedBS :: MonadThrow m => Maybe (Path Abs File) -> ByteString -> m ([PWarning], GenericPackageDescription) #

Read the raw, unresolved package information from a ByteString.

resolvePackage :: PackageConfig -> GenericPackageDescription -> Package #

Resolve a parsed cabal file into a `Package`.

packageFromPackageDescription :: PackageConfig -> GenericPackageDescription -> PackageDescription -> Package #

findOrGenerateCabalFile #

Arguments

:: (MonadThrow m, MonadIO m, MonadLogger m) |
=> Path Abs Dir | package directory
-> m (Path Abs File) |

Get the filename for the cabal file in the given directory.

If no .cabal file is present, or more than one is present, an exception is thrown via `throwM`.

If the directory contains a file named package.yaml, hpack is used to generate a .cabal file from it.

hpack :: (MonadIO m, MonadLogger m) => Path Abs Dir -> m () #

Generate .cabal file from package.yaml, if necessary.

data Package #

Some package info.

Constructors

Package |
Fields packageName :: !PackageName Name of the package. packageVersion :: !Version Version of the package packageLicense :: !License The license the package was released under. packageFiles :: !GetPackageFiles Get all files of the package. packageDeps :: !(Map PackageName VersionRange) Packages that the package depends on. packageTools :: ![Dependency] A build tool name. packageAllDeps :: !(Set PackageName) Original dependencies (not sieved). packageGhcOptions :: ![Text] Ghc options used on package. packageFlags :: !(Map FlagName Bool) Flags used on package. packageDefaultFlags :: !(Map FlagName Bool) Defaults for unspecified flags. packageHasLibrary :: !Bool does the package have a buildable library stanza? packageTests :: !(Map Text TestSuiteInterface) names and interfaces of test suites packageBenchmarks :: !(Set Text) names of benchmarks packageExes :: !(Set Text) names of executables packageOpts :: !GetPackageOpts Args to pass to GHC. packageHasExposedModules :: !Bool Does the package have exposed modules? packageSimpleType :: !Bool Does the package of build-type: Simple packageSetupDeps :: !(Maybe (Map PackageName VersionRange)) If present: custom-setup dependencies

Instances

Eq Package # | Compares the package name.
Methods (==) :: Package -> Package -> Bool # (/=) :: Package -> Package -> Bool #
Ord Package # | Compares the package name.
Methods compare :: Package -> Package -> Ordering # (<) :: Package -> Package -> Bool # (<=) :: Package -> Package -> Bool # (>) :: Package -> Package -> Bool # (>=) :: Package -> Package -> Bool # max :: Package -> Package -> Package # min :: Package -> Package -> Package #
Show Package # |
Methods showsPrec :: Int -> Package -> ShowS # show :: Package -> String # showList :: [Package] -> ShowS #

newtype GetPackageFiles #

Files that the package depends on, relative to package directory. Argument is the location of the .cabal file

Constructors

GetPackageFiles |
Fields getPackageFiles :: forall m env. (StackM env m, HasEnvConfig env) => Path Abs File -> m (Map NamedComponent (Set ModuleName), Map NamedComponent (Set DotCabalPath), Set (Path Abs File), [PackageWarning])

Instances

Show GetPackageFiles # |
Methods showsPrec :: Int -> GetPackageFiles -> ShowS # show :: GetPackageFiles -> String # showList :: [GetPackageFiles] -> ShowS #

newtype GetPackageOpts #

Files that the package depends on, relative to package directory. Argument is the location of the .cabal file

Constructors

GetPackageOpts |
Fields getPackageOpts :: forall env m. (StackM env m, HasEnvConfig env) => SourceMap -> InstalledMap -> [PackageName] -> [PackageName] -> Path Abs File -> m (Map NamedComponent (Set ModuleName), Map NamedComponent (Set DotCabalPath), Map NamedComponent BuildInfoOpts)

Instances

Show GetPackageOpts # |
Methods showsPrec :: Int -> GetPackageOpts -> ShowS # show :: GetPackageOpts -> String # showList :: [GetPackageOpts] -> ShowS #

data PackageConfig #

Package build configuration

Constructors

PackageConfig |
Fields packageConfigEnableTests :: !Bool Are tests enabled? packageConfigEnableBenchmarks :: !Bool Are benchmarks enabled? packageConfigFlags :: !(Map FlagName Bool) Configured flags. packageConfigGhcOptions :: ![Text] Configured ghc options. packageConfigCompilerVersion :: !CompilerVersion GHC version packageConfigPlatform :: !Platform host platform

Instances

Show PackageConfig # |
Methods showsPrec :: Int -> PackageConfig -> ShowS # show :: PackageConfig -> String # showList :: [PackageConfig] -> ShowS #

buildLogPath :: (MonadReader env m, HasBuildConfig env, MonadThrow m) => Package -> Maybe String -> m (Path Abs File) #

Path for the package's build log.

data PackageException #

All exceptions thrown by the library.

Constructors

PackageInvalidCabalFile (Maybe (Path Abs File)) PError |
PackageNoCabalFileFound (Path Abs Dir) |
PackageMultipleCabalFilesFound (Path Abs Dir) [Path Abs File] |
MismatchedCabalName (Path Abs File) PackageName |

Instances

Show PackageException # |
Methods showsPrec :: Int -> PackageException -> ShowS # show :: PackageException -> String # showList :: [PackageException] -> ShowS #
Exception PackageException # |
Methods toException :: PackageException -> SomeException # fromException :: SomeException -> Maybe PackageException # displayException :: PackageException -> String #

resolvePackageDescription :: PackageConfig -> GenericPackageDescription -> PackageDescription #

Get all dependencies of a package, including library, executables, tests, benchmarks.

packageToolDependencies :: PackageDescription -> Map Text VersionRange #

Get all build tool dependencies of the package (buildable targets only).

packageDependencies :: PackageDescription -> Map PackageName VersionRange #

Get all dependencies of the package (buildable targets only).

autogenDir :: Path Abs Dir -> Path Abs Dir #

Make the autogen dir.

checkCabalFileName :: MonadThrow m => PackageName -> Path Abs File -> m () #

Check if the given name in the `Package` matches the name of the .cabal file

printCabalFileWarning :: MonadLogger m => Path Abs File -> PWarning -> m () #

Print cabal file warnings.

cabalFilePackageId :: (MonadIO m, MonadThrow m) => Path Abs File -> m PackageIdentifier #

Extract the `PackageIdentifier` given an exploded haskell package path.