You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--ghc-options specifies options that are used for compilation.
--with-ghc specifies the executable that is used for compilation.
--repl-options specifies options that are used when opening a REPL.
In addition to those, I would love to see:
--with-repl specifies the executable that is used when opening a REPL.
Motivation
This can be useful for running arbitrary tools that require the same command line options as ghci.
Personally, I want to use this with doctest?
As of now, the way I recommend to run doctest with cabal is:
$ cabal repl --with-ghc=doctest
For this to this work, doctest has to proxy all invocations to ghc, unless it sees --interactive, at which point it takes over.
This mostly works, but has the following issues:
The need for doctest to proxy invocations to ghc complicates doctest. While doctest could technically be agnostic to command line options, it currently has to look at them to decide whether to proxy the invocation, or whether to start an API session and ghci to do its thing .
Some packages (notably ghc-paths) will be broken when they are built with doctest proxying to ghc. For that reason, a user needs to take great care to ensure that any such packages have already been built before they invoke doctest in such a manner.
Hm, I think it would make our custom logic to figure out which ghc eactly cabal repl is going to use obsolete. That code has not been a big source of trouble so far, but I am definitely in favour of making it unnecessary.
Thanks @gbaz for your reply. I gave my perspective on code-generators before: #7688 (comment)
We can agree to disagree here, but I want things composable, Unix-style. --with-ghc (or --with-repl for that matter) does not only work for doctest, but also for hspec/sensei, and from what I understand, it is also the approach used by hie-bios. It works without the need to modify the .cabal file. It works for any components, not just libs, and so on.
I imagine that code-generators could work for doctest, and I certainly like the fact that with that approach you can rely on cabal to bring a suitable version of doctest "into scope", but personally, I still put more weight on Unix-style composability.
Finally, even if I would change my stance on doctest, I would still want to use --with-repl for tools that I use during development and that definitely don't belong into the .cabal file (think hspec/sensei, ghcid, or my experimental sol/reserve).
Since cabal-install-3.12.* you can use --repl-multi-file to capture the options that cabal repl would pass to GHC. This is what I currently use for cabal doctest.
This is still not a perfect solution for doctest as cabal repl --with-ghc=doctest <target> will change to the correct working directory for <target>, while cabal doctest <target> is not in a good position to do so. This puts the burden on the user to adjust the working directory as needed (e.g. Makefile: Use cabal doctest #10231).
From the perspective of doctest a --with-repl option is still my preferred solution.
This does seem like a pragmatic thing to add, I didn't before think about the possibility of using a different command for the repl invocation to the one used to build dependencies etc.
It does mean that you have to make sure that your --with-repl script is compatible with the --with-compiler option. But you have to do that anyway if you are messing around with proxying requests using --with-repl.
I wouldn't solve that issue in particular. What we do in hie-bios is we collect the compilation options but we don't keep the $PATH around. It should be possible to do this right now, the harder task is then to modify HLS to set the PATH appropriately depending on the unit.
The bottom line is that doctest users use --with-compiler. I can change the documentation, and I can change cabal-doctest. But this won't change the fact that many users still have --with-compiler in their CI scripts, etc.
The bottom line is that doctest users use --with-compiler. I can change the documentation, and I can change cabal-doctest. But this won't change the fact that many users still have --with-compiler in their CI scripts, etc.
Thanks, I didn't see that.
If doctest now works with response files then --with-compiler should work. We should test that before the release happens.
Release is, for a very short time, blocked to let this testing happen. Who would volunteers to test that and provide reproducible instructions for the test? Later on, we should add the test to the cabal testsuite, but that doesn't block the release.
Activity
sol commentedon Jul 12, 2023
Would
hie-biosbenefit from this as well? @fendorfendor commentedon Jul 12, 2023
Hm, I think it would make our custom logic to figure out which ghc eactly
cabal replis going to use obsolete. That code has not been a big source of trouble so far, but I am definitely in favour of making it unnecessary.andreabedini commentedon Jul 20, 2023
I find the idea of with-repl quite clever but if the goal is to find what arguments to invoke ghc with... cannot we just do that instead?
(I admit I am up to date with the discussion around this topic)
gbaz commentedon Jul 20, 2023
Note that for test stanzas, the code-generators field (https://cabal.readthedocs.io/en/stable/file-format-changelog.html#cabal-version-3-8) will produce all options that would be sent to ghc for a build, and allow invoking a custom executable (via
test). It should provide (and was intended to) a very clean way to run doctest with cabal, and perhaps can be put to the purpose of some other things besides.sol commentedon Jul 21, 2023
Thanks @gbaz for your reply. I gave my perspective on
code-generatorsbefore: #7688 (comment)We can agree to disagree here, but I want things composable, Unix-style.
--with-ghc(or--with-replfor that matter) does not only work fordoctest, but also forhspec/sensei, and from what I understand, it is also the approach used byhie-bios. It works without the need to modify the.cabalfile. It works for any components, not just libs, and so on.I imagine that
code-generatorscould work fordoctest, and I certainly like the fact that with that approach you can rely oncabalto bring a suitable version ofdoctest"into scope", but personally, I still put more weight on Unix-style composability.Finally, even if I would change my stance on
doctest, I would still want to use--with-replfor tools that I use during development and that definitely don't belong into the.cabalfile (thinkhspec/sensei,ghcid, or my experimentalsol/reserve).sol commentedon Jul 21, 2023
That would mean a subcommand (e.g.
repl-options) that prints all the options thatcabalwould pass toghci, right?I think that could be neat, provided that:
--with-repl=echowouldsol commentedon Jul 28, 2024
cabal-install-3.12.*you can use--repl-multi-fileto capture the options thatcabal replwould pass to GHC. This is what I currently use forcabal doctest.doctestascabal repl --with-ghc=doctest <target>will change to the correct working directory for<target>, whilecabal doctest <target>is not in a good position to do so. This puts the burden on the user to adjust the working directory as needed (e.g. Makefile: Usecabal doctest#10231).From the perspective of
doctesta--with-reploption is still my preferred solution.sol commentedon Oct 2, 2024
Another issue with the
--repl-multi-fileworkaround is that it does not bringbuild-toolsinto scope.mpickering commentedon Apr 9, 2025
This does seem like a pragmatic thing to add, I didn't before think about the possibility of using a different command for the repl invocation to the one used to build dependencies etc.
It would also avoid issues like #10915
mpickering commentedon Apr 9, 2025
It does mean that you have to make sure that your
--with-replscript is compatible with the--with-compileroption. But you have to do that anyway if you are messing around with proxying requests using--with-repl.sol commentedon Apr 9, 2025
I would also hope that this will solve the issue with build tools not being in scope for HLS. This is currently a regular annoyance I run into.
fendor commentedon Apr 9, 2025
I wouldn't solve that issue in particular. What we do in
hie-biosis we collect the compilation options but we don't keep the$PATHaround. It should be possible to do this right now, the harder task is then to modify HLS to set the PATH appropriately depending on the unit.18 remaining items
Add --with-repl flag to modify program the "repl" starts with
Add --with-repl flag to modify program the "repl" starts with
mpickering commentedon Jul 9, 2025
@sol @fendor Just want to check that you are both set for 3.16 to include the
--with-replflag in your respective projects?fendor commentedon Jul 9, 2025
hie-bios-0.16 comes with support for
--with-repland we update HLS in haskell/haskell-language-server#4647We plan to do an HLS release before the exe:cabal-3.16 release, that I expect in September.
sol commentedon Jul 10, 2025
@mpickering did you see my comment at #10915 (comment).
The bottom line is that
doctestusers use--with-compiler. I can change the documentation, and I can changecabal-doctest. But this won't change the fact that many users still have--with-compilerin their CI scripts, etc.mpickering commentedon Jul 10, 2025
Thanks, I didn't see that.
If
doctestnow works with response files then--with-compilershould work. We should test that before the release happens.Mikolaj commentedon Jul 10, 2025
Release is, for a very short time, blocked to let this testing happen. Who would volunteers to test that and provide reproducible instructions for the test? Later on, we should add the test to the cabal testsuite, but that doesn't block the release.
Edit: the branch to test is
3.16.sol commentedon Jul 12, 2025
@Mikolaj When I implemented support for response files I tested it with @mpickering's branch. I assume that we are fine.
sol commentedon Jul 12, 2025
Anyway, I double checked again, everything seems fine.
Mikolaj commentedon Jul 12, 2025
@sol: thank you. Release is unblocked.
TODO: Add the
--with-compilertest to CI.fendor commentedon Jul 13, 2025
hie-biostests with cabal HEAD in CI right now.Add --with-repl flag to modify program the "repl" starts with
Add --with-repl flag to modify program the "repl" starts with