Module imports anywhere

Ketil Malde ketil+haskell at ii.uib.no
Tue Oct 24 04:01:57 EDT 2006


Henning Thielemann <haskell at henning-thielemann.de> 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:
>   http://www.haskell.org/pipermail/haskell-cafe/2006-August/017503.html

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?

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



More information about the Haskell-prime mailing list