ErrorT instance of MonadPlus

Hello, ErrorT instance of MonadPlus define that in case of fail both arguments of mplus a value of Error will be the Error of second computation: m `mplus` n = ErrorT $ do a <- runErrorT m case a of Left _ -> runErrorT n Right r -> return (Right r) Could it be changed in this way: m `mplus` n = ErrorT $ do a <- runErrorT m case a of Left e -> do b <- runErrorT n case b of Left e' -> return $ Left (e `eplus` e') r -> return r r -> return r where `eplus` could be placed in class Error a: eplus :: a -> a -> a eplus x y = y -- default implementation In this case we could combine Errors more flexible. Best regards, Dmitry
participants (1)
-
Dmitry Olshansky