doctest
                                
                                 doctest copied to clipboard
                                
                                    doctest copied to clipboard
                            
                            
                            
                        cabal repl --enable-multi-repl --with-ghc=doctest fails with "unrecognized option `-unit'"
The upcoming cabal 3.11 release support loading multiple components (see https://github.com/haskell/cabal/pull/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?
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?
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.
Thanks @mpickering 🙏
To summarize:
- 
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, doctestfails on--unitwhile doing (a). If somebody wants to look into this, then the first step would be to figure out what exactly is going on here.
- 
--enable-multi-replwould 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.
- 
At least for now, I'm not going to look into this myself, but I'm happy to accept contributions. 
possibly related: https://github.com/snoyberg/xml/issues/191 (Setup.hs of that package uses doctest)