[Haskell-cafe] Re: Not to load Prelude

Luke Palmer lrpalmer at gmail.com
Fri Jan 11 15:26:38 EST 2008

On Jan 11, 2008 8:13 PM, Jeremy Shaw <jeremy.shaw at linspireinc.com> wrote:
> At Thu, 10 Jan 2008 22:16:27 -0200,
> Maurí­cio wrote:
> > I tried google and ghc homepage, but could
> > not find "elsewhere" :) Can you give me a
> > link or somewhere to start from?
> No. What I meant to say was, I'm not really sure myself, I just know
> there is a difference and -fno-implicit-prelude is more aggressive. I
> you do find a clear explaination, I would love to see it.

So, when you write the number 3 in Haskell, GHC converts this to
essentially (Prelude.fromInteger (3::Integer)) in its internal format.
 So it doesn't matter if you import Prelude (), Prelude's version of
fromInteger still gets called.  If you give -fno-implicit-prelude,
then this is converted to simply (fromInteger (3::Integer)), without
the hard-coded prelude reference.  That means you could write your own
version of fromInteger that does something different.  A common usage
for -fno-implicit-prelude (insofar as it is used at all, which is
seldom) is to replace the standard Num hierarchy with a saner one,
with numeric literals resolving to that one instead.

There are a few other hard-coded references to Prelude in the internal
format, but I don't remember what they are offhand.
-fno-implicit-prelude gets rid of those, too.


More information about the Haskell-Cafe mailing list