Export lists in modules

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Tue Feb 28 06:52:17 EST 2006


Johannes Waldmann <waldmann at imn.htwk-leipzig.de> wrote:

> > In Haskell, this is called 'fmap'.  :-)
> 
> OK, then show me an "instance Functor Set" so that I can use it :-)

instance Function Set where
    fmap = Data.Set.mapMonotonic

Ok, so this introduces a precondition on the function being mapped, so
there is a proof obligation on the programmer.

But if contexts-on-datatypes worked correctly,

    data Set a = Ord a => ....

then even the "real" map from Data.Set:

    map :: (Ord a, Ord b) => (a -> b) -> Set a -> Set b

could be an instance method of Functor.  (Because the Ord constraints
would be packaged inside the Set type, rather than needing to be
explicit.)

Regards,
    Malcolm


More information about the Haskell-prime mailing list