packages feed

either 4.0 → 4.1

raw patch · 3 files changed

+29/−2 lines, 3 filesdep +monad-controldep +transformers-base

Dependencies added: monad-control, transformers-base

Files

CHANGELOG.markdown view
@@ -1,3 +1,7 @@+4.1+---+* Added instances for `MonadBase`, `MonadBaseControl`, and `MonadTransControl`.+ 4.0 --- * Updated dependencies.
either.cabal view
@@ -1,6 +1,6 @@ name:          either category:      Control, Monads-version:       4.0+version:       4.1 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -28,11 +28,13 @@ library   build-depends:     base          >= 4       && < 5,+    monad-control >= 0.3.2,     MonadRandom   == 0.1.*,     mtl           >= 2.0     && < 2.2,     semigroups    >= 0.8.3.1 && < 1,     semigroupoids >= 4       && < 5,-    transformers  >= 0.2     && < 0.4+    transformers  >= 0.2     && < 0.4,+    transformers-base >= 0.4    extensions: CPP   exposed-modules: Control.Monad.Trans.Either,
src/Control/Monad/Trans/Either.hs view
@@ -7,6 +7,7 @@ {-# LANGUAGE FlexibleContexts      #-} {-# LANGUAGE UndecidableInstances  #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-} ----------------------------------------------------------------------------- -- | -- Module      :  Control.Monad.Trans.Either@@ -32,6 +33,7 @@  import Control.Applicative import Control.Monad (liftM, MonadPlus(..))+import Control.Monad.Base (MonadBase(..), liftBaseDefault) import Control.Monad.Cont.Class import Control.Monad.Error.Class import Control.Monad.Fix@@ -39,6 +41,7 @@ import Control.Monad.Reader.Class import Control.Monad.State (MonadState,get,put) import Control.Monad.Trans.Class+import Control.Monad.Trans.Control (MonadBaseControl(..), MonadTransControl(..), defaultLiftBaseWith, defaultRestoreM) import Control.Monad.Writer.Class import Control.Monad.Random (MonadRandom,getRandom,getRandoms,getRandomR,getRandomRs) import Data.Foldable@@ -265,3 +268,21 @@   traverse f (EitherT a) =     EitherT <$> traverse (either (pure . Left) (fmap Right . f)) a   {-# INLINE traverse #-}++instance (Error e, MonadBase b m) => MonadBase b (EitherT e m) where+  liftBase = liftBaseDefault+  {-# INLINE liftBase #-}++instance Error e => MonadTransControl (EitherT e) where+  newtype StT (EitherT e) a = StEitherT {unStEitherT :: Either e a}+  liftWith f = EitherT $ liftM return $ f $ liftM StEitherT . runEitherT+  {-# INLINE liftWith #-}+  restoreT = EitherT . liftM unStEitherT+  {-# INLINE restoreT #-}++instance (Error e, 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+  {-# INLINE liftBaseWith #-}+  restoreM     = defaultRestoreM unStMEitherT+  {-# INLINE restoreM #-}