There are two schools of thought when it comes to documenting programs and libraries: some embed fragments of code within the documentation (so called “literate programming”) and others embed fragments of documentation in their code (i.e. comments). The “comments” approach makes it easy to generate API documentation and the like (a feature built-in to Haskell’s Hackage system) but help me write blog posts and other documents containing code, which is where literate programming shines. Happily, Haskell supports both of these approaches and has a few rather useful tools available to make both easier. In this post, I’ll describe how to take literate Haskell with Markdown formatted text and produce syntax highlighted documents in HTML and PDF.
I only managed to partially apply the Haskell talk — Yoda speaks Haskell, which was a shame in many ways because the small bit at the end was the most interesting. In the talk I said I wasn't trying to teach these aspects of functional programming, just to show what exists and how they can be used. Basically enough to try to interest people in functional programming by letting them see what they can do and hopefully giving enough to prompt them to go and experiment and learn more about it. In continuing from the end of the talk we had some working code that turned this: [ "fear", "anger", "hate", "suffering" ] Into this: "Fear leads to anger. Anger leads to hate. Hate leads to suffering." The code we had was this¹