Skip to content

Commit a813b85

Browse files
committed
Add code documentation
1 parent 06cecde commit a813b85

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/Stack/Ghci.hs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ data GhciPkgDesc = GhciPkgDesc
182182
{ package :: !Package
183183
, cabalFP :: !(Path Abs File)
184184
, target :: !Target
185+
-- ^ How the package is intended to be built.
185186
}
186187

187188
-- | Type synonym representing maps from a module name to a map with all of the
@@ -292,15 +293,20 @@ ghci opts = do
292293
localTargets
293294
mainFile
294295
pkgs
296+
-- Files targets with unknown GHC options:
295297
(maybe [] snd mfileTargets)
298+
-- The names of packages to be exposed:
296299
(nonLocalTargets ++ addPkgs)
300+
-- A map of package names and sequences of their sublibrary components
301+
-- depended upon (if any):
297302
relevantDependencies
298303

299304
preprocessTargets ::
300305
HasEnvConfig env
301306
=> BuildOptsCLI
302307
-> SMActual GlobalPackage
303308
-> [Text]
309+
-- ^ Raw (unprocessed) targets from the command line.
304310
-> RIO env (Either [Path Abs File] (Map PackageName Target))
305311
preprocessTargets buildOptsCLI sma rawTargets = do
306312
let (fileTargetsRaw, normalTargetsRaw) =
@@ -349,7 +355,12 @@ findFileTargets ::
349355
HasEnvConfig env
350356
=> [LocalPackage]
351357
-> [Path Abs File]
352-
-> RIO env (Map PackageName Target, Map PackageName [Path Abs File], [Path Abs File])
358+
-> RIO
359+
env
360+
( Map PackageName Target
361+
, Map PackageName [Path Abs File]
362+
, [Path Abs File]
363+
)
353364
findFileTargets locals fileTargets = do
354365
filePackages <- forM locals $ \lp -> do
355366
PackageComponentFile _ compFiles _ _ <- getPackageFile lp.package lp.cabalFP
@@ -486,10 +497,17 @@ runGhci ::
486497
=> GhciOpts
487498
-> [(PackageName, (Path Abs File, Target))]
488499
-> Maybe (Path Abs File)
500+
-- ^ Path to source file for selected main module. 'Nothing' if no main
501+
-- module is to be loaded and imported.
489502
-> [GhciPkgInfo]
490503
-> [Path Abs File]
504+
-- ^ Files targets with unknown GHC options.
491505
-> [PackageName]
506+
-- ^ The names of packages to be exposed.
492507
-> Map PackageName (Seq NamedComponent)
508+
-- ^ A map of package names and their sublibraries depended on (if
509+
-- any), the package names to be exposed if any sublibraries are
510+
-- depended on.
493511
-> RIO env ()
494512
runGhci
495513
ghciOpts
@@ -650,8 +668,12 @@ writeHashedFile outputDirectory relFile contents = do
650668
renderScript ::
651669
[GhciPkgInfo]
652670
-> Maybe (Path Abs File)
671+
-- ^ Path to source file for selected main module. 'Nothing' if no main
672+
-- module is to be loaded and imported.
653673
-> Bool
674+
-- ^ Only load and import the main module?
654675
-> [Path Abs File]
676+
-- ^ Files targets with unknown GHC options.
655677
-> GhciScript
656678
renderScript pkgs mainFile onlyMain extraFiles = do
657679
let addPhase = cmdAdd $ S.fromList (map Left allModules ++ addMain)

src/Stack/Ghci/Script.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ instance Monoid GhciScript where
3535

3636
data GhciCommand
3737
= AddCmd (Set (Either ModuleName (Path Abs File)))
38+
-- ^ Add the specified modules (specified by module name or source file) to
39+
-- the current target set and perform a reload (that is, load the target set
40+
-- of modules and the all the modules they depend on in dependency order).
41+
-- The modules specified by name are added first (in ascending order), then
42+
-- the modules specified by source file (in ascending order). The context is
43+
-- set to the most recently successfully loaded module.
3844
| ModuleCmd (Set ModuleName)
45+
-- ^ Add the specified modules to the context. The modules are added in
46+
-- ascending order.
3947
deriving Show
4048

4149
cmdAdd :: Set (Either ModuleName (Path Abs File)) -> GhciScript

src/Stack/Package.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ setOfPackageDeps pkg = runIdentity $
818818
topSortPackageComponent ::
819819
Package
820820
-> Target
821+
-- ^ How the package is intended to be built.
821822
-> Bool
822823
-- ^ Include directTarget or not. False here means we won't include the
823824
-- actual targets in the result, only their deps. Using it with False here
@@ -845,6 +846,7 @@ topProcessPackageComponent ::
845846
forall b.
846847
Package
847848
-> Target
849+
-- ^ How the package is intended to be built.
848850
-> ( forall component. (HasComponentInfo component)
849851
=> PackageType
850852
-> component

src/Stack/Types/GhciOpts.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Stack.Types.BuildOptsCLI ( ApplyCLIFlag (..) )
2020
-- commands.
2121
data GhciOpts = GhciOpts
2222
{ targets :: ![Text]
23+
-- ^ Raw (unprocessed) targets from the command line.
2324
, args :: ![String]
2425
, ghcOptions :: ![String]
2526
, flags :: !(Map ApplyCLIFlag (Map FlagName Bool))
@@ -31,5 +32,6 @@ data GhciOpts = GhciOpts
3132
, hidePackages :: !(Maybe Bool)
3233
, noBuild :: !Bool
3334
, onlyMain :: !Bool
35+
-- ^ Only load and import the main module?
3436
}
3537
deriving Show

0 commit comments

Comments
 (0)