
13 Jul
2010
13 Jul
'10
3 p.m.
On 13 Jul 2010, at 15:51, Brent Yorgey wrote:
If it really is an instance of the Monoid type class then you could just write:
maybeMonoid :: (Monoid a) => Maybe a -> Maybe a -> a maybeMonoid x y = fromMaybe mempty $ liftM2 mappend x y
Aha, yes! that's exactly what I was getting at. Presumably I would also then define Instance Monoid Int where mempty = 0 mappend = (+) (of course, Z also forms a monoid under multiplication, but we're not interested in that in this instance) Cheers, Tim