haskellliterate-programminghaddock

Literate Haskell (.lhs) and Haddock


At the moment I'm only using Haddock but after seeing some really interesting examples (e.g. this gist) of literate Haskell, I'm interested in trying it out in a project.

The questions I got, are:


Solution

  • I used to write a lot of literate programs.

    What do you write as Haddock comments and what do you write in the literate part?

    The external API documentation goes into the Haddock comments. Everything else goes into the literate part. "Everything else" might include:

    How do you scale literate programming to multiple files?

    The same way you scale a large LaTeX document to multiple files: one file per module, then a giant file that \includes them all.

    Can anyone point me to an example where literate programming is used in a package with multiple modules?

    It's not Haskell, but the Quick C-- compiler is a large functional program that is written using literate programming.

    What is your experience of using literate programming in larger packages?

    Literate programming works very well for documenting tricky, difficult, or complex modules. For most simple modules, the external API documentation (e.g., Haddock) is enough. And no literate program is really going to give you the big picture of a design that contains more than a dozen modules. For that you need other tools and techniques.

    Which flavour (markdown, latex, ...) of literate Haskell is preferred?

    If you're making such a major investment, I'd definitely go with LaTeX just because of the math capability, and the generally greater power of the tool.

    Why are you programming in literate Haskell or plain vanilla Haskell? Are you programming in both styles and if so why?

    My Haskell codes are almost always all plain vanilla, for two reasons:

    Do you prefer block-style (\begin{code}) or Bird-style (>)? Why?

    I strongly prefer block style: