replacing the Prelude (again)

Bernard James POPE bjpop@cs.mu.OZ.AU
Mon, 15 Jul 2002 20:11:15 +1000 (EST)


Hi All,

Thanks to everyone for their comments. 

I can see that this is quite a difficult design problem, and it is
unlikely that one solution will please everyone, which makes me think
that the current solution will probably stand.

Simon Peyton-Jones writes:

> Bernie writes:
> | 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?  

I'll get back to you on this soon.

> It would also not be hard to arrange that the "default default"
> declaration became scoped with -fno-implicit-prelude (like fromInteger), if 
> that was useful.   

That sounds a lot like what I would like to have, but I'm probably
being selfish here.

> It's a good point; I thought that *all* the numeric
> stuff was un-coupled from the Prelude with -fno-implicit-prelude, 
> but it isn't quite.

What I would like to know is the semantics of -fno-implicit-prelude with
respect to this bit from the Haskell Report:

   "4.3.4  Ambiguous Types, and Defaults for Overloaded Numeric Operations

   Ambiguities in the class Num are most common, so Haskell provides another 
   way to resolve them---with a default declaration:
   default (t1 , ... , tn)
   where n>=0, and each ti must be a monotype for which Num ti holds. 
                                                  ^^^^^^^^^^
   In situations where an ambiguous type is discovered, an ambiguous type 
   variable is defaultable if at least one of its classes is a numeric class 
   (that is, Num or a subclass of Num) and if all of its classes are defined 
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   in the Prelude or a standard library 
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   Each defaultable variable is replaced by the first type in the default list 
   that is an instance of all the ambiguous variable's classes. It is a 
   static error if no such type is found."

Do these become "whatever Num is in scope" when I use -fno-implicit-prelude,
and "whatever classes from standard libraries" are in scope? If they don't
then I think I'm in a pickle.

Ooroo,
Bernie.