instance Functor Set, was: Re: Export lists in modules

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Wed Mar 1 03:07:34 EST 2006


Jim Apple wrote:

> class MyMap f a b where
>     myMap :: (a -> b) -> f a -> f b
> instance (Functor f) => MyMap f a b where
>     myMap = fmap
> instance (Ord a, Ord b) => MyMap Data.Set.Set a b where
>     myMap = Data.Set.map

OK (I guess).

But my point was that I want to use
"do notation" for Sets (in fact, for any kind of collection)
so I'd need the original Functor and Monad.

I couldn't use ghc's Rebindable Syntax feature
because the types for (>>=) would not match?
http://www.haskell.org/ghc/docs/6.4/html/users_guide/syntax-extns.html#rebindable-syntax

Best regards,
-- 
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------



More information about the Haskell-prime mailing list