id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
3549	unlit does not follow H98 spec	duncan		"The Haskell 98 spec has this to say about the [http://haskell.org/onlinereport/syntax-iso.html Latex \begin{code} \end{code}] style:

    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 are ""a line that begins \begin{code}"" and ""line that begins \end{code}"". This means the semantics is something like:

{{{
classifyLine s
  | ""\\begin{code}"" `isPrefixOf` s = BeginCode
  | ""\\end{code}""   `isPrefixOf` s = EndCode
}}}

GHC's `unlit` C program uses:

{{{
    if (strcmp(buf, ""\\begin{code}"") == 0)
        return BEGIN;
}}}

The equivalent semantics in the style above would be:
{{{
classifyLine s
  | ""\\begin{code}"" == s = BeginCode
  | ""\\end{code}""   == s = EndCode
}}}

It seems fairly clear from the spec that GHC's unlit program is wrong in this respect.

The practical consequence is that Cabal's unlit and GHC's one do not match and this [http://haskell.org/pipermail/haskell-cafe/2009-September/066780.html catches people out]. There is [http://www.haskell.org/haskellwiki/Literate_programming#Hiding_code_from_Haskell explicit advice on the Haskell wiki] recommending that people take advantage of this GHC bug."	bug	new	normal	_|_	Compiler	6.10.4			jmillikin@…	Unknown/Multiple	Unknown/Multiple	None/Unknown	Unknown				
