module Pipes.Lift.EitherT where
import Control.Monad ((>=>))
import Pipes (Proxy, lift)
import Pipes.Lift (distribute)
import Pipes.Internal (unsafeHoist)
import Control.Error (EitherT(..), runEitherT, flipE)
import Pipes.Lift.Error.Instances ()
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
flipEP :: Monad m
=> Proxy a' a b' b (EitherT a m) b
-> Proxy a' a b' b (EitherT b m) a
flipEP = unsafeHoist lift . runEitherT . distribute
>=> lift . EitherT . return . flipE