[Haskell-cafe] doctest-extract

Henning Thielemann lemming at henning-thielemann.de
Mon Aug 3 17:31:13 UTC 2020


On Mon, 3 Aug 2020, Levent Erkok wrote:

> I’m quite interested in this, especially as doctest on GHC 8.10 has
> issues: https://github.com/sol/doctest/issues/264

interesting

> Furthermore, compiling doctests would be a huge performance
> boost and can speed up CI times significantly.

right

> I’m curious why your new package does not support IO-tests. Is that a 
> “current” limitation, or is there a fundamental reason why IO-tests ca 
> not be supported using your approach.

It is a deeper problem.

doctest just runs GHCi and GHCi follows the built-in rule: If an 
expression is IO, then run IO and emit its stdio. If not, print the result 
of "show". That is, in order to make this distinction, doctest-extract 
would have to know the type of the test expression. However, 
doctest-extract extracts purely syntactically, and I prefer to keep it 
this way for simplicity.

For now you may use quickCheck's IO testing. But can it check for stdio 
data?

Alternatively I thought about letting the user mark IO examples in some 
way. Maybe I could ask the user to give a type signature to IO tests and 
switch on expressions that end with ":: IO".


More information about the Haskell-Cafe mailing list