literate haskell

Andrew Rock A.Rock@cit.gu.edu.au
Thu, 21 Mar 2002 22:28:55 +1000


On Thursday, March 21, 2002, at 08:05  PM, Phil Molyneux wrote:

> On Wed, 20 Mar 2002, Jorge Adriano wrote:
>
>> Why is it necessary to leave a blank line between comments and code?
>> I'm using LaTeX  in my lhs files, with the code inside a verbatim
>> environment, and I'd rather start writing my code right after the
>> \begin{verbatim}.
>
> Haskell allows you to use a LaTeX \begin{code}...\end{code} environment 
> to
> signify code in a literate script (Report Appendix C) --- the only snag 
> is
> finding a definition for the ``code'' environment.
>
> The two that work for me are:
>
> (1) Andrew Cooke's haskell.sty -
>
> (2) The fancybox.sty package ---
>

I've been using the fancyvrb package. It has lots of options for
presenting the text including frames, line numbering and font selection.

\usepackage{fancyvrb}
\DefineVerbatimEnvironment{code}{Verbatim}{}
\DefineVerbatimEnvironment{deadcode}{Verbatim}{frame=leftline}

This was recommended to me by someone on comp.lang.functional.
At the time it was also suggested that the TeX and Haskell sources
need not be the primary source, that the .tex file and/or .hs/.lhs
files could be generated from something else.

I took that to heart and wrote this:

http://www.cit.gu.edu.au/~arock/haskell/SimpleLit/SimpleLit.lhs

typeset as:

http://www.cit.gu.edu.au/~arock/haskell/SimpleLit/SimpleLit.pdf

Cheers,
Rock.