Code for hugs and ghc

Till Doerges till@doerges.net
Wed, 7 Nov 2001 12:19:06 +0100


Hi there,

hugs and ghc understand much the same, but a few (often subtle)
differences remain. Since I'd be interested in developing code for
both, I'm looking for a way to directly take care of these differences
in my code.

Ghc offers a commandline option '-cpp' which will allow for '#ifdef'
and other preprocessor directives. When testing it, it worked ok.

Hugs seems to offer a similar feature '-F<cmd>'. When testing it,
however, it did not work. 'cpp' seems to be called, but it seems to
leave characters in the code that can't be dealt w/ by hugs. Moreover,
it seems to called on every input file (i.e. the prelude).

--- snip ---
till@atlan:~/tmp> hugs -Fcpp gammel.hs
__   __ __  __  ____   ___      _________________________________________
||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__||  __||     Copyright (c) 1994-1999
||---||         ___||           World Wide Web: http://haskell.org/hugs
||   ||                         Report bugs to: hugs-bugs@haskell.org
||   || Version: February 2000  _________________________________________
 
Haskell 98 mode: Restart with command line option -98 to enable extensions
 
Reading file "/usr/local/share/hugs/lib/Prelude.hs":
Parsing
ERROR "/usr/local/share/hugs/lib/Prelude.hs" (line 1): Syntax error in input (unexpected symbol "#")
 
FATAL ERROR: Unable to load prelude
--- snap ---


When trying to remove the '#' etc. left in the code by giving '-P' to
cpp it still doesn't work.

--- snip hackcpp.sh ---
cpp -P -D__HUGS__ $1
--- snap hackcpp.sh ---


Here's what happens now:

--- snip ---
till@atlan:~/tmp> hugs -Fhackcpp.sh gammel.hs
__   __ __  __  ____   ___      _________________________________________
||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__||  __||     Copyright (c) 1994-1999
||---||         ___||           World Wide Web: http://haskell.org/hugs
||   ||                         Report bugs to: hugs-bugs@haskell.org
||   || Version: February 2000  _________________________________________
 
Haskell 98 mode: Restart with command line option -98 to enable extensions
 
Reading file "/usr/local/share/hugs/lib/Prelude.hs":
Parsing/usr/local/share/hugs/lib/Prelude.hs:289:22: missing terminating ' character
/usr/local/share/hugs/lib/Prelude.hs:290:28: missing terminating ' character
/usr/local/share/hugs/lib/Prelude.hs:335:58: missing terminating ' character
/usr/local/share/hugs/lib/Prelude.hs:357:63: missing terminating ' character
/usr/local/share/hugs/lib/Prelude.hs:358:29: missing terminating ' character
/usr/local/share/hugs/lib/Prelude.hs:361:63: missing terminating ' character
/usr/local/share/hugs/lib/Prelude.hs:489:17: missing terminating ' character
 
ERROR "/usr/local/share/hugs/lib/Prelude.hs" (line 207): Syntax error in expression (unexpected `=')
 
FATAL ERROR: Unable to load prelude
--- snap ---


My question now is, whether there is a decent (and comfortable) way of
dealing w/ this issue or whether I will have to preprocess the files myself
manually?

Thanks -- Till
-- 
     e-mail: reverse(net dot doerges at till)   | ENCRYPTED |
    pgp/gpg: keys via keyserver or my homepage  |  MAIL IS  |
        www: http://www.doerges.net             |  WELCOME! |