either 3.0.1 → 3.0.2
raw patch · 2 files changed
+11/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Monad.Trans.Either: mapEitherT :: Functor m => (e -> f) -> (a -> b) -> EitherT e m a -> EitherT f m b
Files
- Control/Monad/Trans/Either.hs +10/−0
- either.cabal +1/−1
Control/Monad/Trans/Either.hs view
@@ -2,6 +2,7 @@ module Control.Monad.Trans.Either ( EitherT(..) , eitherT+ , mapEitherT , hoistEither , left , right@@ -39,10 +40,12 @@ instance Ord (m (Either e a)) => Ord (EitherT e m a) where compare = compare `on` runEitherT + eitherT :: Monad m => (a -> m c) -> (b -> m c) -> EitherT a m b -> m c eitherT f g (EitherT m) = m >>= \z -> case z of Left a -> f a Right b -> g b+{-# INLINE eitherT #-} left :: Monad m => e -> EitherT e m a left = EitherT . return . Left@@ -51,6 +54,13 @@ right :: Monad m => a -> EitherT e m a right = return {-# INLINE right #-}+++mapEitherT :: Functor m => (e -> f) -> (a -> b) -> EitherT e m a -> EitherT f m b+mapEitherT f g (EitherT m) = EitherT (fmap h m) where+ h (Left e) = Left (f e)+ h (Right a) = Right (g a)+{-# INLINE mapEitherT #-} hoistEither :: Monad m => Either e a -> EitherT e m a hoistEither = EitherT . return
either.cabal view
@@ -1,6 +1,6 @@ name: either category: Control, Monads-version: 3.0.1+version: 3.0.2 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE