replacing the Prelude (again)

Dylan Thurston
Sat, 13 Jul 2002 18:02:37 -0400

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jul 13, 2002 at 07:58:19PM +1000, Bernard James POPE wrote:
> ...
> I'm fond of the idea proposed by Marcin 'Qrczak' Kowalczyk:
>    May I propose an alternative way of specifying an alternative Prelude?
>    Instead of having a command line switch, let's say that 3 always means
>    Prelude.fromInteger 3 - for any *module Prelude* which is in scope!
>    That is, one could say:
>        import Prelude ()
>        import MyPrelude as Prelude
>    IMHO it's very intuitive, contrary to -fno-implicit-prelude flag.

I don't agree with this, since the Haskell 98 standard explicitly
contradicts it.  I don't see what's wrong with a command line switch
that would do this, anyway.

> Presuming of course that defaulting would follow this path and refer
> to the new Prelude.

I never came up with a design that would allow this.  Defaulting seems
to be the one piece of the Haskell standard for which there is not yet
a general solution.

Although now that I think about it, if you could just specify which
fromInteger you wanted (i.e., give that fromInteger a more specific
type) the problem would go away.  Perhaps that's really the better
solution anyway: how often do people want to default to something
that's not the first on the defaulting list?  I think that might end
up being less surprising to programmers, anyway.  It might work as a
temporary hack for you, anyway.

(That is, add declarations like

fromInteger :: Integer -> Int
fromRational :: Rational -> Double

in your new Prelude.  This would work as long as users don't otherwise
use fromInteger.)

I don't know how you want to transform the types, but there are at
least two areas where there are still special types: List and Bool.
For List, I don't actually see any problem in principle with allowing
other implementations of list comprehensions and whatnot, but Simon
Peyton-Jones indicated that it would be difficult to actually
implement; with Bool, one would need to define additional functions
(like ifThenElse).


Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.0.7 (GNU/Linux)