replacing the Prelude (again)

Malcolm Wallace
Mon, 15 Jul 2002 10:55:32 +0100

> | anymore. What I would like is that the defualting rules refer 
> | to the classes in my version of the Prelude, 
> | not the Standard Prelude.
> You can always get that (with the -fno-implicit-prelude thing) by adding
> 	default [Int, Double]
> or whatever to your source module, just after the import that gets your
> new standard Prelude.  Doesn't that do it?  

We came across the same problem in the Hat tracer (which is also a
source-to-source transformation, and can also be used for debugging).

The problem is that the transformation introduces new classes, so
    Prelude.Ord -> HatPrelude.Ord
    Prelude.Eq  -> HatPrelude.Eq
    Prelude.Num -> HatPrelude.Num

The defaulting mechanism *only* applies to types constrained by
the original builtin Prelude.Num, not to the transformed class

I think you are saying that if we
    import HatPrelude as Prelude
together with -fno-implicit-prelude in GHC, then defaulting should work
over the HatPrelude classes rather than the Prelude ones?

Unfortunately, in Hat at least, we continue to use the original
Prelude in *addition* to the replacement HatPrelude.  So how would
defaulting work in the following?

    {-# -fno-implicit-prelude #-}
    import Prelude as Original
    import HatPrelude as Prelude
    default (Integer,Double)