
On Sep 28, 2009, at 12:21 , Duncan Coutts wrote:
On Sun, 2009-09-27 at 21:06 +0100, John Millikin wrote:
According to <http://www.haskell.org/haskellwiki/ Literate_programming>, the following should compile properly because the second block of code will be ignored by GHC:
\begin{code} main = putStrLn "Hello world!" \end{code}
\begin{code}% main = -- TODO \end{code}%
It looks to me like the advice on that wiki page is incorrect.
The Haskell98 report states:
An alternative style of literate programming is particularly suitable for use with the LaTeX text processing system. In this convention, only those parts of the literate program that are entirely enclosed between \begin{code}...\end{code} delimiters are treated as program text; all other lines are comment. More precisely:
* Program code begins on the first line following a line that begins \begin{code}. * Program code ends just before a subsequent line that begins \end{code} (ignoring string literals, of course).
The key phrases is "a line that begins \begin{code}". In other words, a line "\begin{code}%" does indeed begin a code block.
Isn't the better solution to this something like \let\uncode\code \let\enduncode\endcode then use \begin{uncode} .. \end{uncode} ? (depends on how the code environment is defined) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH