Module imports anywhere

Ketil Malde ketil+haskell at
Tue Oct 24 04:01:57 EDT 2006

Henning Thielemann <haskell at> writes:

>> #if HUGS
>> import Hugs.Base
>> #elseif GHC
>> import GHC.Base
>> #endif

> We just need a system for plugging together system-dependent modules, 
> that's all. We do not need preprocessor hacks for this issue:

But in general, I often find I want to use CPP both to modify imports
and provide function definitions.  E.g. to provide sensible error
messages for some Prelude functions (read, head, fromJust, etc), I
have an include file that imports Prelude hiding the original
definitions, and replace them with macros making use of CPP's __LINE__
and __FILE__.  For some of the support functionality, I'm forced to
write macros instead of functions, since I'd otherwise need to clutter
all my modules with multiple #include statements.

This tends to arise relatively often when I use #include -- if it is
simple to implement, could perhaps this (mixing of imports and
definitions) be allowed when -cpp is specified?

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-prime mailing list