monad-peel 0.1 → 0.1.1
raw patch · 3 files changed
+42/−6 lines, 3 filesdep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: transformers
API changes (from Hackage documentation)
+ Control.Monad.Trans.Peel: liftOp :: (MonadTransPeel t, Monad m, Monad n, Monad o, Monad (t n)) => ((a -> m (t o b)) -> n (t n c)) -> (a -> t m b) -> t n c
+ Control.Monad.Trans.Peel: liftOp_ :: (MonadTransPeel t, Monad m, Monad n, Monad o, Monad (t n)) => (m (t o a) -> n (t n b)) -> t m a -> t n b
Files
- Control/Exception/Peel.hs +2/−4
- Control/Monad/Trans/Peel.hs +38/−0
- monad-peel.cabal +2/−2
Control/Exception/Peel.hs view
@@ -143,8 +143,7 @@ k'' <- peelIO join $ liftIO $ E.bracket_ (k before) (k' after) (k'' thing) --- |Generalized version of 'E.bracketOnError'. Note, any monadic side--- effects in @m@ of the \"release\" computation will be discarded.+-- |Generalized version of 'E.bracketOnError'. bracketOnError :: MonadPeelIO m => m a -- ^ computation to run first (\"acquire resource\") -> (a -> m b) -- ^ computation to run last (\"release resource\")@@ -168,8 +167,7 @@ k' <- peelIO join $ liftIO $ E.finally (k a) (k' sequel) --- |Generalized version of 'E.onException'. Note, any monadic side--- effects in @m@ of the \"afterward\" computation will be discarded.+-- |Generalized version of 'E.onException'. onException :: MonadPeelIO m => m a -> m b -> m a onException m what = do k <- peelIO
Control/Monad/Trans/Peel.hs view
@@ -15,12 +15,17 @@ 'idPeel' and 'liftPeel' are provided to assist creation of @MonadPeelIO@-like classes (see "Control.Monad.IO.Peel") based on core monads other than 'IO'.++'liftOp' and 'liftOp_' enable convenient lifting of two common special+cases of control operation types. -} module Control.Monad.Trans.Peel ( MonadTransPeel(..), idPeel, liftPeel,+ liftOp,+ liftOp_, ) where import Prelude hiding (catch)@@ -196,3 +201,36 @@ return $ \m -> do m' <- k' $ k m return $ join $ lift m'++-- |@liftOp@ is a particular application of 'peel' that allows lifting+-- control operations of type @(a -> m b) -> m b@ to @'MonadTransPeel'+-- t => (a -> t m b) -> t m b@.+--+-- @+-- 'liftOp' f g = do+-- k \<- 'peel'+-- 'join' $ 'lift' $ f (k . g)+-- @+liftOp :: (MonadTransPeel t, Monad m, Monad n, Monad o, Monad (t n)) =>+ ((a -> m (t o b)) -> n (t n c)) -> (a -> t m b) -> t n c+liftOp f g = do+ k <- peel+ join $ lift $ f (k . g)++-- |@liftOp_@ is a particular application of 'peel' that allows+-- lifting control operations of type @m a -> m a@ to+-- @'MonadTransPeel' m => t m a -> t m a@.+--+-- It can be thought of as a generalization of @mapReaderT@,+-- @mapStateT@, etc.+--+-- @+-- 'liftOp_' f m = do+-- k \<- 'peel'+-- 'join' $ 'lift' $ f (k m)+-- @+liftOp_ :: (MonadTransPeel t, Monad m, Monad n, Monad o, Monad (t n)) =>+ (m (t o a) -> n (t n b)) -> t m a -> t n b+liftOp_ f m = do+ k <- peel+ join $ lift $ f (k m)
monad-peel.cabal view
@@ -1,5 +1,5 @@ Name: monad-peel-Version: 0.1+Version: 0.1.1 Synopsis: Lift control operations like exception catching through monad transformers Description: This package defines @MonadPeelIO@, a subset of @MonadIO@ into which@@ -30,4 +30,4 @@ Build-depends: base >= 3 && < 5, extensible-exceptions,- transformers >= 0.2 && < 0.3+ transformers >= 0.2 && < 0.4