Using Cabal to create autogenerated files, without building anything else
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
The Stack project is thinking about what Stack needs to do to prepare for Cabal's changing approach to hooks (https://github.com/commercialhaskell/stack/issues/6542).
Currently, before Stack makes use of `ghc --interactive` (the `stack ghci` or `stack repl` commands), Stack uses Cabal (the library) to create the autogenerated files for every configured component of a package, without building everything. It does so by making use of Cabal's `replHook` and `initialBuildSteps`:
~~~haskell
replHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> ReplFlags -> [String] -> IO ()
initialBuildSteps :: FilePath -> PackageDescription -> LocalBuildInfo -> Verbosity -> IO ()
~~~
(The `replHook` function is supplied with the `PackageDescription` and `LocalBuildInfo` values and the `FilePath` and `Verbosity` values that are needed by `initialBuildSteps` are found within `ReplFlags`.)
I think there are two places Stack could do what it seeks to do:
1. after everything is configured. However, the new scheme for hooks does not have a hook for when everything is configured; `PostConfPackageHook` fires before components are configured and its input `LocalBuildConfig` excludes the part of `LocalBuildInfo` that `initalBuildSteps` needs to know; and
2. before any building starts. The new scheme for hooks has `PreBuildComponentRules`, but it is not clear to me that Cabal can be made to fire the pre-building hooks without actually building anything.
My questions are these:
1. could Cabal have a 'configuration' hook that fires after _everything_ is configured and that supplies (amongst other things) the part of `LocalBuildInfo` that `initialBuildSteps` needs? and/or
2. is it possible to use Cabal (the library) in such a way that the pre-building hooks fire and then Cabal 'stops', without building everything?
Contributor guide
Assessment
This issue has not been assessed yet.