[Haskell-cafe] "doctest" for haskell -- a good project?

Neil Mitchell ndmitchell at gmail.com
Sat Mar 22 13:16:55 EDT 2008


> I once looked at doing this, but I didn't get very far.

Me too, and I managed to get some way:

>  resemble a formal specification.  For a couple of examples, see my
>  RangedSet package and Neil Mitchel's FilePath package.  I manually
>  copied the RangedSet tests into the Haddock documentation, while Neil
>  wrote a small Haskell script to extract his tests from his documentation
>  automatically.  Unfortunately his script is tied to specific aspects of
>  his FilePath package.

Yes, the problem was that FilePath wants to execute half the tests
twice with different modules, and half with just one namespace. As far
as tests go, this is a very wacky requirement. I wanted to generalise
it into a tool, but couldn't find a sensible generalisation that still
worked with filepath - and hence didn't bother. I think the solution
is to not permit the quirkyness of filepath, and write a general
solution for everything else.

As someone who has frequently considered writing this, even going as
far as brainstorming on a whiteboard, I would be an enthusiastic user
of this. I think the lack of this tool in Haskell is a big hole which
someone needs to fill. I particularly like the facility in FilePath:

-- > x == reverse (reverse x)
-- > reverse "neil" = "lien"

i.e. I can write both quickcheck properties (quantified over all
single letter variables), or I can write an instance (like doctest in

Thanks, and good luck!


More information about the Haskell-Cafe mailing list