Maybe doesn't satisfy the monoid properties
asr opened this issue · comments
The Monoid
instance
instance Monoid a => Monoid (Maybe a) where
mempty = Nothing
Nothing `mappend` _ = Nothing
_ `mappend` Nothing = Nothing
Just x1 `mappend` Just x2 = Just (x1 `mappend` x2)
defined in https://github.com/meiersi/strict-base-types/blob/master/src/Data/Maybe/Strict.hs doesn't satisfy the monoid properties. Is it related to the strictness feature?
Hmm, that wouldn't be good. Could you give a concrete counter-example?
Andrés Sicard-Ramírez notifications@github.com schrieb am Do., 28. Jan.
2016 3:32 PM:
The Monoid instance
instance Monoid a => Monoid (Maybe a) where
mempty = NothingNothing
mappend
_ = Nothing
_mappend
Nothing = Nothing
Just x1mappend
Just x2 = Just (x1mappend
x2)defined in
https://github.com/meiersi/strict-base-types/blob/master/src/Data/Maybe/Strict.hs
doesn't satisfy the monoid properties. Is it related to the strictness
feature?—
Reply to this email directly or view it on GitHub
#11.
Could you give a concrete counter-example?
No. But I don't see any problem by fixing the two first equations by
Nothing `mappend` m = m
m `mappend` Nothing = m