[Haskell-cafe] Haddock: inserting interactive sessions in the
documentation
Manlio Perillo
manlio_perillo at libero.it
Mon Mar 30 15:49:13 EDT 2009
Hi.
What is the suggested (if any) convention for inserting an interactive
session in the documentation?
Right know I'm doing (in random-shuffle package):
-- |Convert a sequence @(e1...en)@ to a complete binary tree.
--
-- @
-- System.Random.Shuffle> buildTree ['a','b','c','d','e']
-- Node 5 (Node 4 (Node 2 (Leaf 'a') (Leaf 'b'))
-- (Node 2 (Leaf 'c') (Leaf 'd')))
-- (Leaf 'e')
-- @
buildTree :: [a] -> Tree a
As an example, in Python we use
"""
>>> 3 + 2
5
"""
One nice feature of this special syntax is that it can be parsed, using
doctest.
Thanks Manlio
More information about the Haskell-Cafe
mailing list