
17 Jul
2010
17 Jul
'10
7:54 a.m.
Const has an Applicative instance that doesn't touch the "subject" parameter i.e. the rightmost element of the type. -- Const - drops /b/ newtype Const a b = Const a deriving (Eq,Show) instance Functor (Const a) where fmap f (Const a) = Const a The applicative instance obliges the "data" i.e. the first parameter to be an instance of Monoid: instance Monoid a => Applicative (Const a) where pure b = Const mzero Const f <*> Const v = Const (f `mappend` v)