11-- | This module defines the _exception monad transformer_ `ExceptT`.
22
3- module Control.Monad.Except.Trans
3+ module Control.Monad.Except.Trans
44 ( ExceptT (..), runExceptT , withExceptT , mapExceptT
55 , module Control.Monad.Trans
66 , module Control.Monad.Error.Class
77 ) where
88
9- import Prelude
9+ import Prelude
1010
1111import Data.Tuple (Tuple (..))
1212import Data.Either (Either (..), either )
@@ -18,9 +18,6 @@ import Control.Monad.Rec.Class (MonadRec, tailRecM)
1818import Control.Monad.Eff.Class (MonadEff , liftEff )
1919import Control.Monad.Error.Class (MonadError , throwError , catchError )
2020import Control.Monad.Cont.Class (MonadCont , callCC )
21- import Control.Monad.Reader.Class
22- import Control.Monad.State.Class
23- import Control.Monad.Writer.Class
2421import Control.Monad.RWS.Class
2522import Control.Monad.Trans
2623import Control.MonadPlus (MonadPlus )
@@ -99,29 +96,29 @@ instance monadTransExceptT :: MonadTrans (ExceptT e) where
9996instance monadEffExceptT :: (MonadEff eff m ) => MonadEff eff (ExceptT e m ) where
10097 liftEff = lift <<< liftEff
10198
102- instance monadContExceptT :: (MonadCont m ) => MonadCont (ExceptT e m ) where
99+ instance monadContExceptT :: (MonadCont m ) => MonadCont (ExceptT e m ) where
103100 callCC f = ExceptT $ callCC $ \c -> runExceptT (f (\a -> ExceptT $ c (Right a)))
104101
105102instance monadErrorExceptT :: (Monad m ) => MonadError e (ExceptT e m ) where
106103 throwError = ExceptT <<< pure <<< Left
107104 catchError m handler = ExceptT (runExceptT m >>= either (runExceptT <<< handler) (pure <<< Right ))
108105
109106instance monadReaderExceptT :: (MonadReader r m ) => MonadReader r (ExceptT e m ) where
110- ask = lift ask
107+ ask = lift ask
111108 local f = mapExceptT (local f)
112109
113110instance monadStateExceptT :: (MonadState s m ) => MonadState s (ExceptT e m ) where
114111 state f = lift (state f)
115112
116- instance monadWriterExceptT :: (MonadWriter w m ) => MonadWriter w (ExceptT e m ) where
117- writer wd = lift (writer wd)
118- listen = mapExceptT $ \m -> do
119- Tuple a w <- listen m
113+ instance monadWriterExceptT :: (MonadWriter w m ) => MonadWriter w (ExceptT e m ) where
114+ writer wd = lift (writer wd)
115+ listen = mapExceptT $ \m -> do
116+ Tuple a w <- listen m
120117 return $ (\r -> Tuple r w) <$> a
121- pass = mapExceptT $ \m -> pass $ do
122- a <- m
123- return $ case a of
124- Left e -> Tuple (Left e) id
125- Right (Tuple r f) -> Tuple (Right r) f
118+ pass = mapExceptT $ \m -> pass $ do
119+ a <- m
120+ return $ case a of
121+ Left e -> Tuple (Left e) id
122+ Right (Tuple r f) -> Tuple (Right r) f
126123
127124instance monadRWSExceptT :: (Monoid w , MonadRWS r w s m ) => MonadRWS r w s (ExceptT e m )
0 commit comments