module Pipes.Lift.EitherT where
import Control.Monad ((>=>))
import Pipes (Proxy, MFunctor, hoist, lift)
import Pipes.Lift (distribute)
import Pipes.Internal (unsafeHoist)
import Control.Error (EitherT(..), runEitherT)
instance MFunctor (EitherT e) where
hoist nat m = EitherT (nat (runEitherT m))
eitherP :: Monad m
=> Proxy a' a b' b m (Either e r)
-> Proxy a' a b' b (EitherT e m) r
eitherP = unsafeHoist lift >=> lift . EitherT . return
runEitherP :: Monad m
=> Proxy a' a b' b (EitherT e m) r
-> Proxy a' a b' b m (Either e r)
runEitherP = runEitherT . distribute