Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide way to retrieve current GHC path in a code generator #10632

Open
RyanGlScott opened this issue Dec 10, 2024 · 1 comment
Open

Provide way to retrieve current GHC path in a code generator #10632

RyanGlScott opened this issue Dec 10, 2024 · 1 comment
Labels
re: code-generators Concerning the `code-generators` field/functionality for `testsuite`s type: enhancement

Comments

@RyanGlScott
Copy link
Member

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. As such, in order to programmatically retrieve the GHC path, one has to resort to tricks like what the 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.

Additional context
I encountered this in the context of goldfirere/singletons#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.)

@RyanGlScott RyanGlScott added type: enhancement re: code-generators Concerning the `code-generators` field/functionality for `testsuite`s labels Dec 10, 2024
RyanGlScott referenced this issue in goldfirere/singletons Dec 10, 2024
This replaces `singletons-base`'s custom `Setup.hs` script with a `cabal` code
generator. This finally allows `singletons-base` to have a `Simple` build type,
but at the (relatively less extreme) cost of requiring `Cabal-3.8` or later in
order to build.

Remarkably, everything that the custom `Setup.hs` script did can be done in a
much simpler way with a `cabal` code generator, as all of the information that
the `singletons-base` test suite needs to invoke GHC can be inferred from the
arguments passed to a code generator. One downside is that due to
haskell/cabal#8421, the code generator must be
implemented in a standalone executable package
(`singletons-base-code-generator`). Until that `cabal` issue is fixed, we will
need to upload `singletons-base-code-generator` to Hackage with each
`singletons` release.

Fixes #532.
@ulysses4ever
Copy link
Collaborator

cc @gbaz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: code-generators Concerning the `code-generators` field/functionality for `testsuite`s type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants