either 4.3.4.1 → 4.4
raw patch · 3 files changed
+13/−2 lines, 3 filesdep +mmorphPVP ok
version bump matches the API change (PVP)
Dependencies added: mmorph
API changes (from Hackage documentation)
+ Control.Monad.Trans.Either: instance MFunctor (EitherT e)
Files
- CHANGELOG.markdown +4/−0
- either.cabal +2/−1
- src/Control/Monad/Trans/Either.hs +7/−1
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+4.4+---+* Support `mmorph`+ 4.3.4.1 ------- * Support `MonadRandom` 0.4
either.cabal view
@@ -1,6 +1,6 @@ name: either category: Control, Monads-version: 4.3.4.1+version: 4.4 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -34,6 +34,7 @@ monad-control >= 0.3.2 && < 1.1, MonadRandom >= 0.1 && < 0.5, mtl >= 2.0 && < 2.3,+ mmorph >= 1.0.0 && < 1.0.4, profunctors >= 4 && < 6, semigroups >= 0.8.3.1 && < 1, semigroupoids >= 4 && < 6,
src/Control/Monad/Trans/Either.hs view
@@ -7,6 +7,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} ----------------------------------------------------------------------------- -- |@@ -49,6 +50,7 @@ import Control.Monad.Trans.Control (MonadBaseControl(..), MonadTransControl(..), defaultLiftBaseWith, defaultRestoreM) import Control.Monad.Writer.Class import Control.Monad.Random (MonadRandom,getRandom,getRandoms,getRandomR,getRandomRs)+import Control.Monad.Morph (MFunctor, hoist) import Data.Either.Combinators ( swapEither ) import Data.Foldable import Data.Function (on)@@ -92,6 +94,10 @@ compare = compare `on` runEitherT {-# INLINE compare #-} +instance MFunctor (EitherT e) where+ hoist f = EitherT . f . runEitherT+ {-# INLINE hoist #-}+ -- | Given a pair of actions, one to perform in case of failure, and one to perform -- in case of success, run an 'EitherT' and get back a monadic result. eitherT :: Monad m => (a -> m c) -> (b -> m c) -> EitherT a m b -> m c@@ -343,7 +349,7 @@ {-# INLINE liftWith #-} restoreT = EitherT . liftM unStEitherT {-# INLINE restoreT #-}- + instance MonadBaseControl b m => MonadBaseControl b (EitherT e m) where newtype StM (EitherT e m) a = StMEitherT { unStMEitherT :: StM m (StT (EitherT e) a) } liftBaseWith = defaultLiftBaseWith StMEitherT