Fixups for AMP changes.
This commit is contained in:
parent
5588ba43c8
commit
a8b816730b
2 changed files with 20 additions and 2 deletions
|
@ -20,7 +20,8 @@ module Network.Protocol.TLS.GNU.ErrorT
|
|||
, mapErrorT
|
||||
) where
|
||||
|
||||
import Control.Monad (liftM)
|
||||
import Control.Applicative (Applicative, pure, (<*>))
|
||||
import Control.Monad (ap,liftM)
|
||||
import Control.Monad.Trans (MonadIO, liftIO)
|
||||
import Control.Monad.Trans.Class (MonadTrans, lift)
|
||||
import qualified Control.Monad.Error as E
|
||||
|
@ -35,6 +36,18 @@ newtype ErrorT e m a = ErrorT { runErrorT :: m (Either e a) }
|
|||
instance Functor m => Functor (ErrorT e m) where
|
||||
fmap f = ErrorT . fmap (fmap f) . runErrorT
|
||||
|
||||
instance (Functor m, Monad m) => Applicative (ErrorT e m) where
|
||||
pure a = ErrorT $ return (Right a)
|
||||
f <*> v = ErrorT $ do
|
||||
mf <- runErrorT f
|
||||
case mf of
|
||||
Left e -> return (Left e)
|
||||
Right k -> do
|
||||
mv <- runErrorT v
|
||||
case mv of
|
||||
Left e -> return (Left e)
|
||||
Right x -> return (Right (k x))
|
||||
|
||||
instance Monad m => Monad (ErrorT e m) where
|
||||
return = ErrorT . return . Right
|
||||
(>>=) m k = ErrorT $ do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue