Functor => Pointed => Applicative => Monad
wren ng thornton
wren at freegeek.org
Sun Dec 5 03:50:38 CET 2010
On 12/4/10 6:32 AM, Sebastian Fischer wrote:
> Hi Wren,
> On Sat, 2010-12-04 at 01:25 -0500, wren ng thornton wrote:
>> data SliceUnder a b = SliceUnder (b->a)
>> instance Functor (SliceUnder a) where
>> fmap f (SliceUnder g) = SliceUnder (g . f)
> Couldn't match type `a1' with `b'
Ha, righto! That one's contravariant, whoops.
class ContraFunctor f where
contraMap :: (a -> b) -> (f b -> f a)
instance ContraFunctor (SliceUnder a) where
contraMap f (SliceUnder g) = SliceUnder (g . f)
That'll teach me to rattle things off without typechecking them.
More information about the Libraries