[Haskell-cafe] '#' in literate haskell
John MacFarlane
jgm at berkeley.edu
Sat Nov 29 22:07:33 EST 2008
Can anyone explain why ghc does not treat the following
as a valid literate haskell program?
--------- test.lhs ----
# This is a test
> foo = reverse . words
------------------------
When I try to load this in ghci (or compile it using ghc),
I get:
test.lhs:1:2: lexical error at character 'T'
It seems that the problem is the '#' character in the first
column. Replacing it with something else, or moving it to
the right one space, solves the problem.
The following literate haskell program, from
http://notvincenz.blogspot.com/2008/01/literate-haskell-and-c.html,
also fails to load for me, for the same reason (the leading
'#' in line 8).
---- literate-haskell-and-c.lhs ---
/* c and lhs file
>
> module Foo where
> main = print "Haskell"
>
*/
#include
int main() {
printf("C\n");
return 0;
}
------------------------------------
I've reproduced this with ghc 6.10.1 and ghc 6.8.3 (linux binaries
from haskell.org) and with ghc 6.8.2 (Ubuntu intrepid).
Interestingly, hugs (September 2006 version) has no trouble with
test.lhs. I haven't tried ghc 6.6.
I care about this because I'd like to use markdown conventions
to format the comment parts of literate haskell programs. Markdown
supports atx-style headers, which begin with strings of '#'
characters starting in the first column. I know that some people use
markdown with literate haskell, so there must be something basic here
that I'm missing!
John
More information about the Haskell-Cafe
mailing list