Provide way to retrieve current GHC path in a code generator
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the feature request**
Currently, there does not appear to be a way to retrieve the path of the current GHC version you are using to build a package in the context of a [`cabal` code generator](https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html#pkg-field-test-suite-code-generators). As such, in order to programmatically retrieve the GHC path, one has to resort to tricks like what the [`ghc-paths`](https://hackage.haskell.org/package/ghc-paths) library does. This is unsatisfying for multiple reasons:
* `ghc-paths` requires a custom `Setup.hs` script. One of the key use cases for `cabal` code generators is to _avoid_ custom `Setup.hs` scripts, so needing to depend on a package which uses a custom `Setup.hs` script in order to use a code generator is unfortunate.
* `ghc-paths`'s assumptions about where GHC is installed are [incorrect if you relocate your GHC installation](https://github.com/simonmar/ghc-paths/issues/4).
**Additional context**
I encountered this in the context of https://github.com/goldfirere/singletons/pull/622, in which I replaced `singletons-base`'s custom `Setup.hs` script with a code generator. While using `ghc-paths` as part of this solution mostly works, I am missing the ability to _completely_ remove the dependency on custom `Setup.hs` scripts due to the need for a `ghc-paths` dependency. (This dependency is only used in the `singletons-base` test suite, however, so the situation is not as severe as when the entire `singletons-base` library required a custom `Setup.hs` script.)
Contributor guide
Assessment
This issue has not been assessed yet.