EitherT 0.1.0 → 0.2.0
raw patch · 2 files changed
+40/−4 lines, 2 filesdep +monad-controldep +transformersdep +transformers-basedep −mtlPVP ok
version bump matches the API change (PVP)
Dependencies added: monad-control, transformers, transformers-base
Dependencies removed: mtl
API changes (from Hackage documentation)
+ Control.Monad.Trans.Either: instance MonadBase b m => MonadBase b (EitherT l m)
+ Control.Monad.Trans.Either: instance MonadBaseControl b m => MonadBaseControl b (EitherT l m)
+ Control.Monad.Trans.Either: instance MonadTransControl (EitherT l)
Files
- EitherT.cabal +2/−2
- src/Control/Monad/Trans/Either.hs +38/−2
EitherT.cabal view
@@ -1,5 +1,5 @@ Name: EitherT-Version: 0.1.0+Version: 0.2.0 Synopsis: EitherT monad transformer Description: Support for computations with informative failures. License: BSD3@@ -10,6 +10,6 @@ Stability: experimental Build-Type: Simple HS-Source-Dirs: src-Build-Depends: base >= 4 && < 5, mtl >= 2.0 && < 2.1+Build-Depends: base >= 4 && < 5, transformers >= 0.2, transformers-base >= 0.4, monad-control >= 0.3 Exposed-modules: Control.Monad.Trans.Either ghc-options: -Wall
src/Control/Monad/Trans/Either.hs view
@@ -1,13 +1,17 @@ {-# OPTIONS -Wall -O2 -fno-warn-orphans #-}+{-# LANGUAGE CPP, FlexibleInstances, MultiParamTypeClasses,+ UndecidableInstances, TypeFamilies #-} module Control.Monad.Trans.Either(EitherT(..), left) where import Data.Monoid(Monoid(..)) import Control.Monad(liftM)-import Control.Monad.Trans(MonadTrans(..))+import Control.Monad.Trans.Class(MonadTrans(..)) import Control.Monad.Instances()-import Control.Monad.Trans(MonadIO(..))+import Control.Monad.IO.Class(MonadIO(..)) import Control.Applicative(Applicative(..), liftA2)+import Control.Monad.Base+import Control.Monad.Trans.Control newtype EitherT l m a = EitherT { runEitherT :: m (Either l a) } inEitherT0 :: m (Either l a) -> EitherT l m a@@ -49,3 +53,35 @@ instance (Applicative m, Monoid a) => Monoid (EitherT l m a) where mempty = pure mempty mappend = liftA2 mappend++instance MonadBase b m => MonadBase b (EitherT l m) where+ liftBase = liftBaseDefault++instance MonadTransControl (EitherT l) where+ newtype StT (EitherT l) r = StEither {unStEither :: Either l r}+ liftWith f = EitherT $ liftM return $ f $ liftM StEither . runEitherT+ restoreT = EitherT . liftM unStEither+ {-# INLINE liftWith #-}+ {-# INLINE restoreT #-}+{-+instance (MonadBaseControl b m) => MonadBaseControl b (Either l m) where+ newType StM (EitherT l m) a = StMEither { unStMEither :: ComposeSt (EitherT l) m a }+ liftBaseWith = defaultLiftBaseWith StMEither+ restoreM = defaultRestoreM unSTMEither+ {-# INLINE liftBaseWith #-}+ {-# INLINE restoreM #-}+-}++--Copied from monad-control-0.3.1.1.+#define BODY(T, ST, unST) { \+ newtype StM (T m) a = ST {unST :: ComposeSt (T) m a}; \+ liftBaseWith = defaultLiftBaseWith ST; \+ restoreM = defaultRestoreM unST; \+ {-# INLINE liftBaseWith #-}; \+ {-# INLINE restoreM #-}}++--Copied from monad-control-0.3.1.1.+#define TRANS( T, ST, unST) \+ instance ( MonadBaseControl b m) => MonadBaseControl b (T m) where BODY(T, ST, unST)++TRANS(EitherT l, StMEither, unStMEither)