Recent version of Hugs can use a preprocessor for mangling Haskell files
(via the -F flag). But there's a problem in the order of preprocessing
steps: The Haskell file is piped through given the preprocessor (normally
cpp, cc -E, or the short Perl script in the Installation hints) *before*
the literate stuff is removed. If the recommended Perl script is used,
#line-pragmas are converted into Haskell comments, which results in
errors from the de-litifier.

Example: Consider the following short Main.lhs:

   > main = putStrLn "foo"

is converted to

   # 1 "x.hs"
   > main = putStrLn "foo"

by the C-preprocessor, which is in turn mangled to

   {-# LINE 1 "x.hs" -}
   > main = putStrLn "foo"

by the Perl script. Alas, this is not a legal literate script.
("Program line next to comment")

There are two solutions for this:

   * Emit an empty line before and after the {-# LINE ... -}  (Hack)

   * Swap the two preprocessing stages as GHC does.

And a related point: It would be nice if Hugs called the preprocessor
with -D__HUGS__ (or something similar). Without a standardised name
to test for in #ifdefs, the whole preprocessing stuff is not as useful
as it could be.

-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne

Reply via email to