-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Sensible conversions between some of the monad transformers -- -- Sensible conversions between MaybeT and EitherT monad transformers. @package transformers-convert @version 0.2.0.0 module Control.Monad.Trans.Convert -- | Transform a maybe value encapsulated in a Monad m into the -- equivalent MaybeT m monad transformer. -- -- NOTE: this is not equivalent to either lift or -- hoistMaybe alone. Check the types carefully. mMaybeToMaybeT :: Monad m => m (Maybe a) -> MaybeT m a -- | Shorter alias for mMaybeToMaybeT mMToMT :: Monad m => m (Maybe a) -> MaybeT m a -- | Transform a IO (Maybe a) value into a MaybeT IO a value ioMaybeToMaybeT :: IO (Maybe a) -> MaybeT IO a -- | Shorter alias for ioMaybeToMaybeT ioMToMT :: IO (Maybe a) -> MaybeT IO a -- | Transform a either value encapsulated in a Monad m into the -- equivalent MaybeT m monad transformer. -- -- Note: The left value is silently discarded. mEitherToMaybeT :: Functor m => m (Either a b) -> MaybeT m b -- | Shorter alias for mEitherToMaybeT. mEToMT :: (Functor m, Monad m) => m (Either a b) -> MaybeT m b -- | Transform a either value encapsulated in a IO monad into the -- equivalent MaybeT IO monad transformer. -- -- Note: The left value is silently discarded. ioEitherToMaybeT :: IO (Either a b) -> MaybeT IO b -- | Shorter alias for mEitherToMaybeT. ioEToMT :: IO (Either a b) -> MaybeT IO b -- | Case analysis of a pair of monoid values returned by a monad into a -- MaybeT value. The value conversion is done by -- pairToMaybe. mPairToMaybeT :: (Eq a, Monoid a, Functor m, Monad m) => m (a, a) -> MaybeT m a -- | Case analysis of a pair of monoid values returned by a monad into a -- MaybeT value. The value conversion is done by -- pairToMaybe'. mPairToMaybeT' :: (Eq a, Monoid a, Functor m, Monad m) => m (a, a) -> MaybeT m a -- | Case analysis of a pair of monoid values returned by a monad into a -- MaybeT value. The value conversion is done by -- pairFstToMaybe. mPairFstToMaybeT :: (Eq a, Monoid a, Functor m, Monad m) => m (a, b) -> MaybeT m a -- | Case analysis of a pair of monoid values returned by a monad into a -- MaybeT value. The value conversion is done by -- pairSndToMaybe. mPairSndToMaybeT :: (Eq b, Monoid b, Functor m, Monad m) => m (a, b) -> MaybeT m b -- | Transform a monoid value encapsulated in a Monad m into the -- equivalent MaybeT m monad transformer (mempty -> -- Nothing). mMonoidToMaybeT :: (Eq o, Monoid o, Functor m, Monad m) => m o -> MaybeT m o -- | Shorter alias for mMonoidToMaybeT mOToMT :: (Eq o, Monoid o, Functor m, Monad m) => m o -> MaybeT m o -- | Transform a boolean value encapsulated in a Monad m into the -- equivalent MaybeT m monad transformer (True -> -- Provided Default Value). mBoolToMaybeT :: (Functor m, Monad m) => a -> m Bool -> MaybeT m a -- | Shorter alias for mBoolToMaybeT. mBToMT :: (Functor m, Monad m) => a -> m Bool -> MaybeT m a tryIOMonoidToMaybeT :: (Eq a, Monoid a) => IO a -> MaybeT IO a tryIOMT :: (Eq a, Monoid a) => IO a -> MaybeT IO a -- | Transform a maybe value encapsulated in a Monad m into the -- equivalent EitherT b m monad transformer. -- -- NOTE: this is not equivalent to either lift or -- hoistEither alone. Check the types carefully. mMaybeToEitherT :: Monad m => b -> m (Maybe a) -> EitherT b m a -- | Shorter alias for mMaybeToEitherT mMToET :: Monad m => b -> m (Maybe a) -> EitherT b m a -- | Transform a IO (Maybe a) value into a EitherT b IO a value ioMaybeToEitherT :: b -> IO (Maybe a) -> EitherT b IO a -- | Shorter alias for ioMaybeToEitherT ioMToET :: b -> IO (Maybe a) -> EitherT b IO a -- | Transform a either value encapsulated in a Monad m into the -- equivalent EitherT e m monad transformer. mEitherToEitherT :: Monad m => m (Either b a) -> EitherT b m a -- | Shorter alias for mEitherToEitherT. mEToET :: Monad m => m (Either b a) -> EitherT b m a -- | Transform a either value encapsulated in a IO monad into the -- equivalent EitherT b IO monad transformer. ioEitherToEitherT :: IO (Either b a) -> EitherT b IO a -- | Shorter alias for mEitherToEitherT. ioEToET :: IO (Either b a) -> EitherT b IO a -- | Case analysis of a pair of monoid values returned by a monad into a -- EitherT value. The value conversion is done by -- pairToEither. mPairToEitherT :: (Eq a, Monoid a, Functor m, Monad m) => m (b, a) -> EitherT b m a -- | Case analysis of a pair of monoid values returned by a monad into a -- EitherT value. The value conversion is done by -- pairToEither'. mPairToEitherT' :: (Eq b, Monoid b, Functor m, Monad m) => m (b, a) -> EitherT a m b -- | Case analysis of a pair of monoid values returned by a monad into a -- EitherT value. The value conversion is done by -- pairBothToEither. mPairBothToEitherT :: (Eq a, Monoid a, Functor m, Monad m) => b -> m (a, a) -> EitherT b m a -- | Transform a monoid value encapsulated in a Monad m into the -- equivalent EitherT e m monad transformer (mempty -> -- Nothing). mMonoidToEitherT :: (Eq a, Monoid a, Functor m, Monad m) => b -> m a -> EitherT b m a -- | Shorter alias for mMonoidToEitherT mOToET :: (Eq a, Monoid a, Functor m, Monad m) => b -> m a -> EitherT b m a -- | Transform a boolean value encapsulated in a Monad m into the -- equivalent Either m monad transformer. Uses -- boolToEither. mBoolToEitherT :: (Functor m, Monad m) => b -> a -> m Bool -> EitherT b m a -- | Shorter alias for mBoolToEitherT. mBToET :: (Functor m, Monad m) => b -> a -> m Bool -> EitherT b m a -- | Change the left type using the provided conversion function. This is a -- specialization of bimapEitherT. -- --
-- fmapLeftT f = bimapEitherT f id ---- -- or using the errors Data.EitherR -- --
-- fmapLeftT = fmapLT --fmapLeftT :: Functor m => (a -> c) -> EitherT a m b -> EitherT c m b -- | Change the right type using the provided conversion function. This is -- a specialization of bimapEitherT. fmapRightT :: Functor m => (b -> c) -> EitherT a m b -> EitherT a m c tryIOMonoidToEitherT :: (Eq a, Monoid a) => IO a -> EitherT IOException IO a -- | This function executes a IO action that could raise an -- IOException. If a IOException is -- raised, the function returns a left value in the EitherT -- IOException IO monad transformer. tryIOET :: IO a -> EitherT IOException IO a -- | This function executes a IO action that returns a monoid value, or -- raises an IOException. If a -- IOException is raised, or the returned value is an -- empty monoid, the function returns a left value in the EitherT -- IOException IO monad transformer. In the later case (empty -- monoid), the exception will be of userErrorType type, -- with the provided string text. tryIOET' :: (Eq a, Monoid a) => String -> IO a -> EitherT IOException IO a