Skip to content

Commit 8de108b

Browse files
committed
Merge pull request #18 from purescript-contrib/errort
Simplify superinstance constraints for ErrorT
2 parents f219dd9 + a05983d commit 8de108b

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/Control/Monad/Error/Trans.purs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Control.Monad.Error.Trans where
22

3+
import Control.Apply
34
import Control.Alt
45
import Control.Alternative
56
import Control.Plus
@@ -21,18 +22,10 @@ mapErrorT f m = ErrorT $ f (runErrorT m)
2122
instance 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

3831
instance altErrorT :: (Monad m, Error e) => Alt (ErrorT e m) where

0 commit comments

Comments
 (0)