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 1
1
module Control.Monad.Error.Trans where
2
2
3
+ import Control.Apply
3
4
import Control.Alt
4
5
import Control.Alternative
5
6
import Control.Plus
@@ -21,18 +22,10 @@ mapErrorT f m = ErrorT $ f (runErrorT m)
21
22
instance functorErrorT :: (Functor m ) => Functor (ErrorT e m ) where
22
23
(<$>) f = ErrorT <<< (<$>) ((<$>) f) <<< runErrorT
23
24
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
34
27
35
- instance applicativeErrorT :: (Functor m , Monad m ) => Applicative (ErrorT e m ) where
28
+ instance applicativeErrorT :: (Applicative m ) => Applicative (ErrorT e m ) where
36
29
pure a = ErrorT $ pure $ Right a
37
30
38
31
instance altErrorT :: (Monad m , Error e ) => Alt (ErrorT e m ) where
You can’t perform that action at this time.
0 commit comments