doctest icon indicating copy to clipboard operation
doctest copied to clipboard

Add ability to start a cabal repl/GHCi session from a doctest

Open mantkiew opened this issue 10 years ago • 2 comments

One of the complaints people have about REPL is that the context or setup is lost when you :reload. However, they are both preserved in doctests. It would be great to be able to open a REPL session from a doctest. It would support both the interactive development of doctests and REPL-style development (see Reddit discussion and the subsequent writeup Use the REPL, Luke.

That could be invoked using

doctest --command="cabal repl" Fib.hs

or

doctest --command=ghci Fib.hs

or even

doctest --command="stack ghci" Fib.hs

Similarly how you specify the command for ghcid.

mantkiew avatar Jul 16 '15 12:07 mantkiew

@mantkiew Sorry for the late reply. In case you are still interested in this, I would need more information. doctest clears the scope between example groups. So for the question is, at which point (or with what scope) would you want doctest to give you a GHCi session?

sol avatar Jul 26 '17 04:07 sol

Could you give it a line number for "first test after this line"? (Or, if it's easier, a top-level function name?) Then I could hit a key in Emacs and run a doctest immediately :-)

unhammer avatar Sep 14 '18 10:09 unhammer