purescript / purescript-prelude

The PureScript Prelude
BSD 3-Clause "New" or "Revised" License
162 stars 88 forks source link

Semiring Maybe instance is badly behaved #45

Closed hdgarrood closed 8 years ago

hdgarrood commented 8 years ago

Semiring has the following law:

With the instance (Semiring a) => Semiring (Maybe a), neither of these hold for a = Nothing - since mul is defined as liftA2 mul, zero * Nothing = Nothing, but zero = Just zero. Changing the definition of zero to be Nothing could fix this but might break other laws, I'm not sure. Maybe we should just remove this instance.

garyb commented 8 years ago

I think this issue is open on the wrong repo? :)

Maybe also has a non-law-abiding MonadPlus instance that we should remove while we're at it.

hdgarrood commented 8 years ago

Oh yes, of course. Oops.