
On 3/6/07, Ross Paterson
There is another, combining two Justs using a Monoid instance on the argument. It could be argued that this is an even better candidate for the "obvious" instance on Maybe.
Good point. I see two instances that satisfy the monoid laws here too: -- | Lift a 'Monoid' into 'Maybe' instance Monoid a => Monoid (Maybe a) where mempty = Nothing Nothing `mappend` m = m m `mappend` Nothing = m Just m1 `mappend` Just m2 = Just (m1 `mappend` m2) instance Monoid a => Monoid (Maybe a) where mempty = Just mempty Just m1 `mappend` Just m2 = Just (m1 `mappend` m2) _ `mappend` _ = Nothing David, your instance doesn't satisfy (mempty `mappend` r == r) I think the first instance is more useful. If the list agrees, I'm happy to add it into my patch. Jeffrey