FiniteMap: modifyFM

Hal Daume III hdaume@ISI.EDU
Wed, 19 Jun 2002 11:00:39 -0700 (PDT)

Yes, I agree with your [Possibly not...] statement, which I why I think
I'm in favor of having the "two Preludes" option, but having both standard
(this is part of my reason for not adopting Ashley's Prelude).

I think a reasonable way to do it would be to have

module AdvancedPrelude

which defines the map, fold, etc functions all in their own class,
something like:

class Map m a where
  map :: (a -> b) -> m a -> m b
  mapAccum :: ...

and so on.  It also defines things like Group, Ring, etc.

The standard Prelude then imports the Advanced prelude, hiding all the map
classes and imports the Group and Ring but doesn't export them; instead it
wraps them into Num, etc., as we have now.  It also defines the map,
etc. functions over lists as we normally do.

You then can either import neither, in which case you get the Prelude,
explicitly import AdvancedPrelude, in which case you get the Advanced
prelude but not the Prelude, import both (in which case you're screwed).

The "importing AdvancedPrelude => no import Prelude" may rub some folks
the wrong way, but it's really only marginally different from the (imo
strange) rules regarding how importing the prelude works today...if you
don't import it, you get it, or if you import it hiding things, that
cancels out the automatic import, etc...

I don't know if such a thing is possible, but it would be nice to have a
standard but more advnaced prelude.

Hal Daume III

 "Computer science is no more about computers    |
  than astronomy is about telescopes." -Dijkstra |

On 19 Jun 2002, Alastair Reid wrote:

> > So...yeah...I've kind of lost my train of thought, but I think that
> > the problem I've frequently had is that I want to use the names the
> > prelude uses, but can't.  :).
> Back when Haskell 1.4 (or 98?) was being designed, I proposed that
> Haskell's rule that the Prelude is implicitly imported into every
> module should be dropped.  Benefit: simpler language, easier to
> replace Prelude with your own.  Cost: requires you to type 2 extra
> tokens in every module and to ask students to type it in without first
> giving them a full explanation of what it means.  Didn't get anywhere.
> I'm wondering if that would help at all?
> [Possibly not.  When I worked on Yale Haskell (which was written in
> Lisp), I cursed and swore at the Lisp hackers who seemed to have
> defined their own personal subset of Lisp in which every symbol meant
> something slightly different from what it meant in any one Lisp.  That
> is, one of Haskell's goals was to create a common language for all
> lazy language research so it might be a mistake to make fragmentation
> easy.]
> --
> Alastair