[Haskell-beginners] Fwd: My first functioning haskell project - a steganography utility

Tim Cowlishaw tim at timcowlishaw.co.uk
Tue Jul 13 11:20:44 EDT 2010


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

actually, looking at it again, it'd be something like

maybeMonoid :: (Monoid a) =>  Maybe a -> Maybe a -> a
maybeMonoid ::  x y = (fromMaybe mempty x) `mappend` (fromMaybe mempty y)

Cheers,

Tim


More information about the Beginners mailing list