Skip to content

Commit

Permalink
Merge pull request #18 from purescript-contrib/errort
Browse files Browse the repository at this point in the history
Simplify superinstance constraints for ErrorT
  • Loading branch information
paf31 committed Sep 4, 2014
2 parents f219dd9 + a05983d commit 8de108b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/Control/Monad/Error/Trans.purs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Control.Monad.Error.Trans where

import Control.Apply
import Control.Alt
import Control.Alternative
import Control.Plus
Expand All @@ -21,18 +22,10 @@ mapErrorT f m = ErrorT $ f (runErrorT m)
instance functorErrorT :: (Functor m) => Functor (ErrorT e m) where
(<$>) f = ErrorT <<< (<$>) ((<$>) f) <<< runErrorT

instance applyErrorT :: (Functor m, Monad m) => Apply (ErrorT e m) where
(<*>) f v = ErrorT $ do
mf <- runErrorT f
case mf of
Left e -> return $ Left e
Right k -> do
mv <- runErrorT v
return case mv of
Left e -> Left e
Right x -> Right (k x)
instance applyErrorT :: (Apply m) => Apply (ErrorT e m) where
(<*>) (ErrorT f) (ErrorT v) = ErrorT $ lift2 ($) <$> f <*> v

instance applicativeErrorT :: (Functor m, Monad m) => Applicative (ErrorT e m) where
instance applicativeErrorT :: (Applicative m) => Applicative (ErrorT e m) where
pure a = ErrorT $ pure $ Right a

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

0 comments on commit 8de108b

Please sign in to comment.