literate haskell

Keith Wansbrough Keith.Wansbrough@cl.cam.ac.uk
Wed, 20 Mar 2002 17:41:25 +0000


> 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}.

Use

\begin{code}
fac    0  = 0
fac (n+1) = (n+1) * fac n
\end{code}

instead of

\begin{verbatim}

> fac    0  = 0
> fac (n+1) = (n+1) * fac n

\end{verbatim}

and then define the `code' environment to do verbatim typesetting.  You could start by looking at the LaTeX verbatim.sty package, or moreverb.sty, or simply copy the code for \verbatim and \endverbatim from latex.ltx with appropriate modifications (the latter is probably NOT recommended for the faint-hearted!).

(Haskell knows about both styles of literate comments, and the top one is designed for what you are doing).

HTH.

--KW 8-)
-- 
Keith Wansbrough <kw217@cl.cam.ac.uk>
http://www.cl.cam.ac.uk/users/kw217/
University of Cambridge Computer Laboratory.