on ab5feba help sign in
stackage/Stackage/Types.hs
93 lines 3.7 kB history raw
1module Stackage.Types
2 ( module X
3 , module Stackage.Types
4 ) where
6import Data.Map as X (Map)
7import Data.Map (unionWith)
8import Data.Monoid (Monoid (..))
9import Data.Set as X (Set)
10import Data.Version as X (Version)
11import Distribution.Package as X (PackageIdentifier (..),
12 PackageName (..))
13import Distribution.Version as X (VersionRange (..))
14import Distribution.PackageDescription (GenericPackageDescription)
16newtype PackageDB = PackageDB (Map PackageName PackageInfo)
17 deriving (Show, Eq)
19instance Monoid PackageDB where
20 mempty = PackageDB mempty
21 PackageDB x `mappend` PackageDB y =
22 PackageDB $ unionWith newest x y
23 where
24 newest pi1 pi2
25 | piVersion pi1 > piVersion pi2 = pi1
26 | otherwise = pi2
28data PackageInfo = PackageInfo
29 { piVersion :: Version
30 , piDeps :: Map PackageName VersionRange
31 , piHasTests :: Bool
32 , piBuildTools :: Set PackageName
33 , piGPD :: Maybe GenericPackageDescription
34 }
35 deriving (Show, Eq)
37-- | Information on a package we're going to build.
38data BuildInfo = BuildInfo
39 { biVersion :: Version
40 , biUsers :: [PackageName]
41 , biMaintainer :: Maintainer
42 , biDeps :: Map PackageName VersionRange
43 }
45data HaskellPlatform = HaskellPlatform
46 { hpcore :: Set PackageIdentifier
47 , hplibs :: Set PackageIdentifier
48 }
49 deriving (Show, Eq, Ord)
50instance Monoid HaskellPlatform where
51 mempty = HaskellPlatform mempty mempty
52 HaskellPlatform a x `mappend` HaskellPlatform b y = HaskellPlatform (mappend a b) (mappend x y)
54data InstallInfo = InstallInfo
55 { iiCore :: Set PackageName
56 , iiPackages :: Map PackageName (Version, Maintainer)
57 , iiOptionalCore :: Map PackageName Version
58 -- ^ This is intended to hold onto packages which might be automatically
59 -- provided in the global package database. In practice, this would be
60 -- Haskell Platform packages provided by distributions.
61 , iiPackageDB :: PackageDB
62 }
64-- | Email address of a Stackage maintainer.
65newtype Maintainer = Maintainer { unMaintainer :: String }
66 deriving (Show, Eq, Ord)
68data BuildSettings = BuildSettings
69 { sandboxRoot :: FilePath
70 , extraBuildArgs :: [String]
71 , extraCore :: Set PackageName
72 , expectedFailures :: Set PackageName
73 , stablePackages :: Map PackageName (VersionRange, Maintainer)
74 , extraArgs :: [String]
75 , haskellPlatformCabal :: FilePath
76 , requireHaskellPlatform :: Bool
77 , cleanBeforeBuild :: Bool
78 , excludedPackages :: Set PackageName
79 -- ^ Packages which should be dropped from the list of stable packages,
80 -- even if present via the Haskell Platform or @stablePackages@. If these
81 -- packages are dependencies of others, they will still be included.
82 , testWorkerThreads :: Int
83 -- ^ How many threads to spawn for running test suites.
84 , flags :: Set String
85 -- ^ Compile flags which should be turned on.
86 , allowedPackage :: GenericPackageDescription -> Either String ()
87 -- ^ Checks if a package is allowed into the distribution. By default, we
88 -- allow all packages in, though this could be used to filter out certain
89 -- untrusted packages, or packages with an unacceptable license.
90 --
91 -- Returns a reason for stripping in Left, or Right if the package is
92 -- allowed.
93 }