While testing the MonadFail patches I've noticed (since they trigger warnings/errors) that in Data.Aeson.Types.Internal there's a Monad-instance lacking a custom fail method implementation:
-- | The result of running a 'Parser'.
data Result a = Error String
| Success a
deriving (Eq, Show, Typeable)
instance Monad Result where
return = Success
Success a >>= k = k a
Error path err >>= _ = Error path err
even though an obvious implementation may be fail = Error
However, the following code fragments refer to fail explicitly, resulting in partial definitions:
instance MonadPlus Result where
mzero = fail "mzero"
mplus a@(Success _) _ = a
mplus _ b = b
instance Monoid (Result a) where
mempty = fail "mempty"
mappend = mplus
While testing the
MonadFail
patches I've noticed (since they trigger warnings/errors) that inData.Aeson.Types.Internal
there's aMonad
-instance lacking a customfail
method implementation:even though an obvious implementation may be
fail = Error
However, the following code fragments refer to
fail
explicitly, resulting in partial definitions:...was this an oversight or deliberate?
/cc @quchen