@@ -7,7 +7,7 @@ import Data.Either
77import Data.Monoid
88import Data.Tuple
99
10- data ErrorT e m a = ErrorT (m (Either e a ))
10+ newtype ErrorT e m a = ErrorT (m (Either e a ))
1111
1212runErrorT :: forall e m a . ErrorT e m a -> m (Either e a )
1313runErrorT (ErrorT x) = x
@@ -17,7 +17,7 @@ mapErrorT f m = ErrorT $ f (runErrorT m)
1717
1818instance functorErrorT :: (Functor m ) => Functor (ErrorT e m ) where
1919 (<$>) f = ErrorT <<< (<$>) ((<$>) f) <<< runErrorT
20-
20+
2121instance applyErrorT :: (Functor m , Monad m ) => Apply (ErrorT e m ) where
2222 (<*>) f v = ErrorT $ do
2323 mf <- runErrorT f
@@ -28,10 +28,10 @@ instance applyErrorT :: (Functor m, Monad m) => Apply (ErrorT e m) where
2828 return case mv of
2929 Left e -> Left e
3030 Right x -> Right (k x)
31-
31+
3232instance applicativeErrorT :: (Functor m , Monad m ) => Applicative (ErrorT e m ) where
3333 pure a = ErrorT $ pure $ Right a
34-
34+
3535instance alternativeErrorT :: (Monad m , Error e ) => Alternative (ErrorT e m ) where
3636 empty = ErrorT (return (Left $ strMsg " No alternative" ))
3737 (<|>) x y = ErrorT $ runErrorT x >>= \e -> case e of
@@ -44,9 +44,9 @@ instance bindErrorT :: (Monad m, Error e) => Bind (ErrorT e m) where
4444 case a of
4545 Left e -> return $ Left e
4646 Right x -> runErrorT (f x)
47-
47+
4848instance monadErrorT :: (Monad m , Error e ) => Monad (ErrorT e m )
49-
49+
5050instance monadTransErrorT :: (Error e ) => MonadTrans (ErrorT e ) where
5151 lift m = ErrorT $ do
5252 a <- m
0 commit comments