Skip to content

Simplify superinstance constraints for ErrorT #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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