Understand relationship between stack repl
and Cabal (the library) repl
#6548
Open
Description
Motivation:
- @sheaf's observations here: RFC: Replacing the Cabal Custom build-type haskellfoundation/tech-proposals#60 (comment) ...
- ... here: Prepare Stack for Cabal's changing approach to hooks #6542 (comment) ...
- ... here: Using Cabal to create autogenerated files, without building anything else haskell/cabal#9857 (comment) ...
- ... and here: Restore
Distribution.Simple.Build.initialBuildSteps
to Cabal's API haskell/cabal#9856 (comment).
Is there a reason that Stack avoids the use of Cabal (the library) repl
(from Cabal >= 2.2)?
Context:
Stack.Build.ExecutePackage.realConfigAndBuild
(extracts):
case ( ee.buildOptsCLI.onlyConfigure
, ee.buildOptsCLI.initialBuildSteps && taskIsTarget task
) of
...
(_, True) | null ac.downstream || installedMapHasThisPkg -> do
initialBuildSteps cabal announce
...
where
...
initialBuildSteps cabal announce = do
announce ("initial-build-steps" <> display annSuffix)
cabal KeepTHLoading ["repl", "stack-initial-build-steps"]
Stack.GhciCmd.ghciCmd
(extracts):
ghciCmd ghciOpts =
let boptsCLI = defaultBuildOptsCLI
{ ...
, initialBuildSteps = True
...
}
in withConfig YesReexec $ withEnvConfig AllowNoTargets boptsCLI $ do
bopts <- view buildOptsL
-- override env so running of tests and benchmarks is disabled
let boptsLocal = bopts
{ testOpts = bopts.testOpts { TestOpts.disableRun = True }
, benchmarkOpts =
bopts.benchmarkOpts { BenchmarkOpts.disableRun = True }
}
local (set buildOptsL boptsLocal) (ghci ghciOpts)
Stack.GhciCmd.ghci
(extracts):
-- | Launch a GHCi session for the given project package targets with the given
-- options and configure it with the load paths and extensions of those targets.
ghci :: HasEnvConfig env => GhciOpts -> RIO env ()
ghci opts = do
...
-- Build required dependencies and setup project packages.
buildDepsAndInitialSteps opts $
concatMap (\(pn, (_, t)) -> pkgTargets pn t) localTargets
...
-- Finally, do the invocation of ghci
runGhci
opts
localTargets
mainFile
pkgs
(maybe [] snd mfileTargets)
(nonLocalTargets ++ addPkgs)
relevantDependencies
History:
- May 2015: Analogue of cabal repl #130 (at that time, there were aspects of Cabal's
repl
that the Stack project did not want to emulate)