Johannes Waldmann <[EMAIL PROTECTED]> 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
_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://haskell.org/mailman/listinfo/haskell-prime

Reply via email to