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.
Semiring
has the following law:zero * a = zero
With the instance
(Semiring a) => Semiring (Maybe a)
, neither of these hold fora = Nothing
- sincemul
is defined asliftA2 mul
,zero * Nothing = Nothing
, butzero = Just zero
. Changing the definition ofzero
to beNothing
could fix this but might break other laws, I'm not sure. Maybe we should just remove this instance.