33{-# LANGUAGE NoFieldSelectors #-}
44{-# LANGUAGE OverloadedRecordDot #-}
55
6- -- | A sourcemap maps a package name to how it should be built, including source
7- -- code, flags, options, etc. This module contains various stages of source map
8- -- construction. See the @build_overview.md@ doc for details on these stages.
6+ -- | A source map maps a package name to how it should be built, including
7+ -- source code, flags and options. This module exports types used in various
8+ -- stages of source map construction. See @build_overview.md@ for details on
9+ -- these stages.
910module Stack.Types.SourceMap
10- ( -- * Different source map types
11+ ( -- * Source map types
1112 SMWanted (.. )
1213 , SMActual (.. )
1314 , Target (.. )
@@ -56,8 +57,8 @@ data CommonPackage = CommonPackage
5657 -- ^ Should Haddock documentation be built for this package?
5758 }
5859
59- -- | Flag showing if package comes from a snapshot needed to ignore dependency
60- -- bounds between such packages
60+ -- | Flag showing if package comes from a snapshot. Used to ignore dependency
61+ -- bounds between such packages.
6162data FromSnapshot
6263 = FromSnapshot
6364 | NotFromSnapshot
@@ -75,16 +76,20 @@ data DepPackage = DepPackage
7576 -- See https://github.com/commercialhaskell/stackage/issues/3185
7677 }
7778
78- -- | A view of a project package needed for resolving components
79+ -- | A view of a project package. Used to resolve components.
7980data ProjectPackage = ProjectPackage
8081 { projectCommon :: ! CommonPackage
8182 , cabalFP :: ! (Path Abs File )
8283 , resolvedDir :: ! (ResolvedPath Dir )
8384 }
8485
85- -- | A view of a package installed in the global package database also could
86- -- include marker for a replaced global package (could be replaced because of a
87- -- replaced dependency)
86+ -- | A type representing versions of packages in the global package database.
87+ newtype GlobalPackageVersion
88+ = GlobalPackageVersion Version
89+
90+ -- | A view of a package installed in the global package database or a marker
91+ -- for a replaced global package. A global package could be replaced because of
92+ -- a replaced dependency.
8893data GlobalPackage
8994 = GlobalPackage ! Version
9095 | ReplacedGlobalPackage ! [PackageName ]
@@ -94,6 +99,16 @@ isReplacedGlobal :: GlobalPackage -> Bool
9499isReplacedGlobal (ReplacedGlobalPackage _) = True
95100isReplacedGlobal (GlobalPackage _) = False
96101
102+ -- | A type representing how a package is intended to be built.
103+ data Target
104+ = TargetAll ! PackageType
105+ -- ^ Build all of the default components.
106+ | TargetComps ! (Set NamedComponent )
107+ -- ^ Only build specific components
108+
109+ data PackageType = PTProject | PTDependency
110+ deriving (Eq , Show )
111+
97112-- | A source map with information on the wanted (but not actual) compiler. This
98113-- is derived by parsing the @stack.yaml@ file for @packages@, @extra-deps@,
99114-- their configuration (e.g., flags and options), and parsing the snapshot it
@@ -110,8 +125,9 @@ data SMWanted = SMWanted
110125 -- ^ Where this snapshot is loaded from.
111126 }
112127
113- -- | Adds in actual compiler information to 'SMWanted', in particular the
114- -- contents of the global package database.
128+ -- | A source map with information on the actual compiler, including the
129+ -- contents of its global package database. It does not include any information
130+ -- from the command line.
115131--
116132-- Invariant: a @PackageName@ appears in only one of the @Map@s.
117133data SMActual global = SMActual
@@ -121,19 +137,6 @@ data SMActual global = SMActual
121137 , globals :: ! (Map PackageName global )
122138 }
123139
124- newtype GlobalPackageVersion
125- = GlobalPackageVersion Version
126-
127- -- | How a package is intended to be built
128- data Target
129- = TargetAll ! PackageType
130- -- ^ Build all of the default components.
131- | TargetComps ! (Set NamedComponent )
132- -- ^ Only build specific components
133-
134- data PackageType = PTProject | PTDependency
135- deriving (Eq , Show )
136-
137140-- | Builds on an 'SMActual' by resolving the targets specified on the command
138141-- line, potentially adding in new dependency packages in the process.
139142data SMTargets = SMTargets
@@ -143,6 +146,9 @@ data SMTargets = SMTargets
143146
144147-- | The final source map, taking an 'SMTargets' and applying all command line
145148-- flags and GHC options.
149+ --
150+ -- One source map value is distinguished from another by a hash of the parts of
151+ -- the value that are immutable.
146152data SourceMap = SourceMap
147153 { targets :: ! SMTargets
148154 -- ^ Doesn't need to be included in the hash, does not affect the source
0 commit comments