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

cabal repl --enable-multi-repl --with-ghc=doctest fails with "unrecognized option `-unit'" #412

Open
TristanCacqueray opened this issue Aug 20, 2023 · 4 comments

Comments

@TristanCacqueray
Copy link

The upcoming cabal 3.11 release support loading multiple components (see haskell/cabal#8726). However this does not seems to work when running doctest through ghc replacement. Here is an example failure for a package using two libraries:

$ cabal repl --enable-multi-repl --with-ghc=doctest butler butler-desktop

Resolving dependencies...
Build profile: -w ghc-9.6.2 -O1
In order, the following will be built (use -v for more details):
 - butler-0.1 (interactive) (lib) (first run)
 - butler-0.1 (interactive) (lib:butler-desktop) (configuration changed)
Preprocessing library for butler-0.1...
Configuring library 'butler-desktop' for butler-0.1...
Preprocessing library 'butler-desktop' for butler-0.1...
doctest: unrecognized option `-unit'
Try `doctest --help' for more information.

Could we make this work?

@sol
Copy link
Owner

sol commented Sep 7, 2023

Doctest uses both, the GHC compilation pipeline and GHCi.

  • the GHC compilation pipeline is used for extracting Haddock comments
  • GHCi is used to evaluate examples

If multiple home units are only supported by GHCi, but not by the GHC compilation pipeline, then I think it would be hard to support multiple home units.

Taking a step back, do you think this is crucial? As I understand it, the motivation for multiple home units is to enable :reload to work across multiple units. This is useful for interactive use, but doesn't offer any benefit for Doctest.

@mpickering do you have any input?

@mpickering
Copy link

It seems like it would be possible to make doctest start a multi unit session if passed -unit arguments. It could be useful if you have doctests in all of your different components.

Multiple home units are supported by the GHC compilation pipeline.

@sol
Copy link
Owner

sol commented Sep 8, 2023

Thanks @mpickering 🙏

To summarize:

  1. Doctest accepts arbitrary GHC arguments and uses these to:

    (a) initialize a GHC session and extract Haddock comments, and then
    (b) passes them to GHCi

    Apparently, as of now, doctest fails on --unit while doing (a). If somebody wants to look into this, then the first step would be to figure out what exactly is going on here.

  2. --enable-multi-repl would allow you to run all doctests of a package with a single command. Other than that, i'm not aware of any additional benefits. Iterating through all the units of a package and running Doctest for each unit individually should work equally well.

  3. At least for now, I'm not going to look into this myself, but I'm happy to accept contributions.

@jwaldmann
Copy link

possibly related: snoyberg/xml#191 (Setup.hs of that package uses doctest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants