stack-1.4.0: The Haskell Tool Stack

Safe Haskell | None
Language | Haskell2010

Stack.BuildPlan

Description

Resolving a build plan for a set of packages in a given Stackage snapshot.

Synopsis

- data BuildPlanException
  - = UnknownPackages (Path Abs File) (Map PackageName (Maybe Version, Set PackageName)) (Map PackageName (Set PackageIdentifier))
  - | SnapshotNotFound SnapName
  - | FilepathInDownloadedSnapshot Text
  - | NeitherCompilerOrResolverSpecified Text
- data BuildPlanCheck
  - = BuildPlanCheckOk (Map PackageName (Map FlagName Bool))
  - | BuildPlanCheckPartial (Map PackageName (Map FlagName Bool)) DepErrors
  - | BuildPlanCheckFail (Map PackageName (Map FlagName Bool)) DepErrors CompilerVersion
- checkSnapBuildPlan :: (StackM env m, HasConfig env, HasGHCVariant env) => [GenericPackageDescription] -> Maybe (Map PackageName (Map FlagName Bool)) -> SnapName -> m BuildPlanCheck
- data DepError = DepError {
  - deVersion :: !(Maybe Version)
  - deNeededBy :: !(Map PackageName VersionRange)
  }
- type DepErrors = Map PackageName DepError
- gpdPackageDeps :: GenericPackageDescription -> CompilerVersion -> Platform -> Map FlagName Bool -> Map PackageName VersionRange
- gpdPackages :: [GenericPackageDescription] -> Map PackageName Version
- gpdPackageName :: GenericPackageDescription -> PackageName
- data MiniBuildPlan = MiniBuildPlan {
  - mbpCompilerVersion :: !CompilerVersion
  - mbpPackages :: !(Map PackageName MiniPackageInfo)
  }
- data MiniPackageInfo = MiniPackageInfo {
  - mpiVersion :: !Version
  - mpiFlags :: !(Map FlagName Bool)
  - mpiGhcOptions :: ![Text]
  - mpiPackageDeps :: !(Set PackageName)
  - mpiToolDeps :: !(Set Text)
  - mpiExes :: !(Set ExeName)
  - mpiHasLibrary :: !Bool
  - mpiGitSHA1 :: !(Maybe GitSHA1)
  }
- loadResolver :: (StackMiniM env m, HasConfig env, HasGHCVariant env) => Maybe (Path Abs File) -> Resolver -> m (MiniBuildPlan, LoadedResolver)
- loadMiniBuildPlan :: (StackMiniM env m, HasConfig env, HasGHCVariant env) => SnapName -> m MiniBuildPlan
- removeSrcPkgDefaultFlags :: [GenericPackageDescription] -> Map PackageName (Map FlagName Bool) -> Map PackageName (Map FlagName Bool)
- resolveBuildPlan :: (StackMiniM env m, HasBuildConfig env) => MiniBuildPlan -> (PackageName -> Bool) -> Map PackageName (Set PackageName) -> m (Map PackageName (Version, Map FlagName Bool), Map PackageName (Set PackageName))
- selectBestSnapshot :: (StackM env m, HasConfig env, HasGHCVariant env) => [GenericPackageDescription] -> NonEmpty SnapName -> m (SnapName, BuildPlanCheck)
- getToolMap :: MiniBuildPlan -> Map Text (Set PackageName)
- shadowMiniBuildPlan :: MiniBuildPlan -> Set PackageName -> (MiniBuildPlan, Map PackageName MiniPackageInfo)
- showItems :: Show a => [a] -> Text
- showPackageFlags :: PackageName -> Map FlagName Bool -> Text
- parseCustomMiniBuildPlan :: (StackMiniM env m, HasConfig env, HasGHCVariant env) => Maybe (Path Abs File) -> Text -> m (MiniBuildPlan, SnapshotHash)
- loadBuildPlan :: (StackMiniM env m, HasConfig env) => SnapName -> m BuildPlan

# Documentation

data BuildPlanException #

Constructors

UnknownPackages (Path Abs File) (Map PackageName (Maybe Version, Set PackageName)) (Map PackageName (Set PackageIdentifier)) |
SnapshotNotFound SnapName |
FilepathInDownloadedSnapshot Text |
NeitherCompilerOrResolverSpecified Text |

Instances

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

data BuildPlanCheck #

Constructors

BuildPlanCheckOk (Map PackageName (Map FlagName Bool)) |
BuildPlanCheckPartial (Map PackageName (Map FlagName Bool)) DepErrors |
BuildPlanCheckFail (Map PackageName (Map FlagName Bool)) DepErrors CompilerVersion |

Instances

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

checkSnapBuildPlan :: (StackM env m, HasConfig env, HasGHCVariant env) => [GenericPackageDescription] -> Maybe (Map PackageName (Map FlagName Bool)) -> SnapName -> m BuildPlanCheck #

Check a set of `GenericPackageDescription`s and a set of flags against a given snapshot. Returns how well the snapshot satisfies the dependencies of the packages.

data DepError #

Constructors

DepError |
Fields deVersion :: !(Maybe Version) deNeededBy :: !(Map PackageName VersionRange)

Instances

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

type DepErrors = Map PackageName DepError #

gpdPackageDeps :: GenericPackageDescription -> CompilerVersion -> Platform -> Map FlagName Bool -> Map PackageName VersionRange #

gpdPackages :: [GenericPackageDescription] -> Map PackageName Version #

gpdPackageName :: GenericPackageDescription -> PackageName #

data MiniBuildPlan #

A simplified version of the `BuildPlan` + cabal file.

Constructors

MiniBuildPlan |
Fields mbpCompilerVersion :: !CompilerVersion mbpPackages :: !(Map PackageName MiniPackageInfo)

Instances

Eq MiniBuildPlan # |
Methods (==) :: MiniBuildPlan -> MiniBuildPlan -> Bool # (/=) :: MiniBuildPlan -> MiniBuildPlan -> Bool #
Data MiniBuildPlan # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MiniBuildPlan -> c MiniBuildPlan # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MiniBuildPlan # toConstr :: MiniBuildPlan -> Constr # dataTypeOf :: MiniBuildPlan -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c MiniBuildPlan) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MiniBuildPlan) # gmapT :: (forall b. Data b => b -> b) -> MiniBuildPlan -> MiniBuildPlan # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MiniBuildPlan -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MiniBuildPlan -> r # gmapQ :: (forall d. Data d => d -> u) -> MiniBuildPlan -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MiniBuildPlan -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MiniBuildPlan -> m MiniBuildPlan # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MiniBuildPlan -> m MiniBuildPlan # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MiniBuildPlan -> m MiniBuildPlan #
Show MiniBuildPlan # |
Methods showsPrec :: Int -> MiniBuildPlan -> ShowS # show :: MiniBuildPlan -> String # showList :: [MiniBuildPlan] -> ShowS #
Generic MiniBuildPlan # |
Associated Types type Rep MiniBuildPlan :: * -> * # Methods from :: MiniBuildPlan -> Rep MiniBuildPlan x # to :: Rep MiniBuildPlan x -> MiniBuildPlan #
NFData MiniBuildPlan # |
Methods rnf :: MiniBuildPlan -> () #
Store MiniBuildPlan # |
Methods size :: Size MiniBuildPlan # poke :: MiniBuildPlan -> Poke () # peek :: Peek MiniBuildPlan #
type Rep MiniBuildPlan # |
type Rep MiniBuildPlan = D1 (MetaData "MiniBuildPlan" "Stack.Types.BuildPlan" "stack-1.4.0-5VbagGyw9hyAgBJq8WQvrq" False) (C1 (MetaCons "MiniBuildPlan" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "mbpCompilerVersion") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 CompilerVersion)) (S1 (MetaSel (Just Symbol "mbpPackages") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Map PackageName MiniPackageInfo)))))

data MiniPackageInfo #

Information on a single package for the `MiniBuildPlan`.

Constructors

MiniPackageInfo |
Fields mpiVersion :: !Version mpiFlags :: !(Map FlagName Bool) mpiGhcOptions :: ![Text] mpiPackageDeps :: !(Set PackageName) mpiToolDeps :: !(Set Text) Due to ambiguity in Cabal, it is unclear whether this refers to the executable name, the package name, or something else. We have to guess based on what's available, which is why we store this is an unwrapped `Text`. mpiExes :: !(Set ExeName) Executables provided by this package mpiHasLibrary :: !Bool Is there a library present? mpiGitSHA1 :: !(Maybe GitSHA1) An optional SHA1 representation in hex format of the blob containing the cabal file contents. Useful for grabbing the correct cabal file revision directly from a Git repo

Instances

Eq MiniPackageInfo # |
Methods (==) :: MiniPackageInfo -> MiniPackageInfo -> Bool # (/=) :: MiniPackageInfo -> MiniPackageInfo -> Bool #
Data MiniPackageInfo # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MiniPackageInfo -> c MiniPackageInfo # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MiniPackageInfo # toConstr :: MiniPackageInfo -> Constr # dataTypeOf :: MiniPackageInfo -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c MiniPackageInfo) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MiniPackageInfo) # gmapT :: (forall b. Data b => b -> b) -> MiniPackageInfo -> MiniPackageInfo # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MiniPackageInfo -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MiniPackageInfo -> r # gmapQ :: (forall d. Data d => d -> u) -> MiniPackageInfo -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MiniPackageInfo -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MiniPackageInfo -> m MiniPackageInfo # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MiniPackageInfo -> m MiniPackageInfo # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MiniPackageInfo -> m MiniPackageInfo #
Show MiniPackageInfo # |
Methods showsPrec :: Int -> MiniPackageInfo -> ShowS # show :: MiniPackageInfo -> String # showList :: [MiniPackageInfo] -> ShowS #
Generic MiniPackageInfo # |
Associated Types type Rep MiniPackageInfo :: * -> * # Methods from :: MiniPackageInfo -> Rep MiniPackageInfo x # to :: Rep MiniPackageInfo x -> MiniPackageInfo #
NFData MiniPackageInfo # |
Methods rnf :: MiniPackageInfo -> () #
Store MiniPackageInfo # |
Methods size :: Size MiniPackageInfo # poke :: MiniPackageInfo -> Poke () # peek :: Peek MiniPackageInfo #
type Rep MiniPackageInfo # |
type Rep MiniPackageInfo = D1 (MetaData "MiniPackageInfo" "Stack.Types.BuildPlan" "stack-1.4.0-5VbagGyw9hyAgBJq8WQvrq" False) (C1 (MetaCons "MiniPackageInfo" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "mpiVersion") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Version)) (S1 (MetaSel (Just Symbol "mpiFlags") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Map FlagName Bool)))) ((:*:) (S1 (MetaSel (Just Symbol "mpiGhcOptions") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [Text])) (S1 (MetaSel (Just Symbol "mpiPackageDeps") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Set PackageName))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "mpiToolDeps") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Set Text))) (S1 (MetaSel (Just Symbol "mpiExes") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Set ExeName)))) ((:*:) (S1 (MetaSel (Just Symbol "mpiHasLibrary") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Bool)) (S1 (MetaSel (Just Symbol "mpiGitSHA1") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe GitSHA1)))))))

loadResolver :: (StackMiniM env m, HasConfig env, HasGHCVariant env) => Maybe (Path Abs File) -> Resolver -> m (MiniBuildPlan, LoadedResolver) #

loadMiniBuildPlan :: (StackMiniM env m, HasConfig env, HasGHCVariant env) => SnapName -> m MiniBuildPlan #

Load up a `MiniBuildPlan`, preferably from cache

removeSrcPkgDefaultFlags :: [GenericPackageDescription] -> Map PackageName (Map FlagName Bool) -> Map PackageName (Map FlagName Bool) #

resolveBuildPlan #

Arguments

:: (StackMiniM env m, HasBuildConfig env) |
=> MiniBuildPlan |
-> (PackageName -> Bool) | is it shadowed by a local package?
-> Map PackageName (Set PackageName) | required packages, and users of it
-> m (Map PackageName (Version, Map FlagName Bool), Map PackageName (Set PackageName)) |

Determine the necessary packages to install to have the given set of packages available.

This function will not provide test suite and benchmark dependencies.

This may fail if a target package is not present in the `BuildPlan`.

selectBestSnapshot :: (StackM env m, HasConfig env, HasGHCVariant env) => [GenericPackageDescription] -> NonEmpty SnapName -> m (SnapName, BuildPlanCheck) #

Find a snapshot and set of flags that is compatible with and matches as best as possible with the given `GenericPackageDescription`s.

getToolMap :: MiniBuildPlan -> Map Text (Set PackageName) #

Map from tool name to package providing it

shadowMiniBuildPlan :: MiniBuildPlan -> Set PackageName -> (MiniBuildPlan, Map PackageName MiniPackageInfo) #

showItems :: Show a => [a] -> Text #

showPackageFlags :: PackageName -> Map FlagName Bool -> Text #

parseCustomMiniBuildPlan #

Arguments

:: (StackMiniM env m, HasConfig env, HasGHCVariant env) |
=> Maybe (Path Abs File) | Root directory for when url is a filepath
-> Text |
-> m (MiniBuildPlan, SnapshotHash) |

loadBuildPlan :: (StackMiniM env m, HasConfig env) => SnapName -> m BuildPlan #

Load the `BuildPlan` for the given snapshot. Will load from a local copy if available, otherwise downloading from Github.