File tree Expand file tree Collapse file tree 1 file changed +4
-11
lines changed
Expand file tree Collapse file tree 1 file changed +4
-11
lines changed Original file line number Diff line number Diff line change 11module Control.Monad.Error.Trans where
22
3+ import Control.Apply
34import Control.Alt
45import Control.Alternative
56import Control.Plus
@@ -21,18 +22,10 @@ mapErrorT f m = ErrorT $ f (runErrorT m)
2122instance functorErrorT :: (Functor m ) => Functor (ErrorT e m ) where
2223 (<$>) f = ErrorT <<< (<$>) ((<$>) f) <<< runErrorT
2324
24- instance applyErrorT :: (Functor m , Monad m ) => Apply (ErrorT e m ) where
25- (<*>) f v = ErrorT $ do
26- mf <- runErrorT f
27- case mf of
28- Left e -> return $ Left e
29- Right k -> do
30- mv <- runErrorT v
31- return case mv of
32- Left e -> Left e
33- Right x -> Right (k x)
25+ instance applyErrorT :: (Apply m ) => Apply (ErrorT e m ) where
26+ (<*>) (ErrorT f) (ErrorT v) = ErrorT $ lift2 ($) <$> f <*> v
3427
35- instance applicativeErrorT :: (Functor m , Monad m ) => Applicative (ErrorT e m ) where
28+ instance applicativeErrorT :: (Applicative m ) => Applicative (ErrorT e m ) where
3629 pure a = ErrorT $ pure $ Right a
3730
3831instance altErrorT :: (Monad m , Error e ) => Alt (ErrorT e m ) where
You can’t perform that action at this time.
0 commit comments