pipes-safe 2.3.4 → 2.3.5
raw patch · 5 files changed
+43/−21 lines, 5 filesdep ~basedep ~containersdep ~primitivePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, containers, primitive
API changes (from Hackage documentation)
- Pipes.Safe: data SafeT m r
- Pipes.Safe: type family Base (m :: Type -> Type) :: Type -> Type;
+ Pipes.Safe: SafeT :: ReaderT (Env m) m r -> SafeT m r
+ Pipes.Safe: data Env m
+ Pipes.Safe: newtype SafeT m r
+ Pipes.Safe: type Base (m :: Type -> Type) :: Type -> Type;
Files
- LICENSE +2/−2
- README.md +3/−3
- changelog.md +4/−0
- pipes-safe.cabal +10/−10
- src/Pipes/Safe.hs +24/−6
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2013, 2014 Gabriel Gonzalez+Copyright (c) 2013, 2014 Gabriella Gonzalez All rights reserved. Redistribution and use in source and binary forms, with or without modification,@@ -8,7 +8,7 @@ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.- * Neither the name of Gabriel Gonzalez nor the names of other contributors+ * Neither the name of Gabriella Gonzalez nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
README.md view
@@ -1,7 +1,7 @@ # Pipes-Safe `pipes-safe` builds upon-[the `pipes` library](https://github.com/Gabriel439/Haskell-Pipes-Library) to+[the `pipes` library](https://github.com/Gabriella439/Haskell-Pipes-Library) to provide exception safety and resource management. ## Quick start@@ -55,7 +55,7 @@ ## License (BSD 3-clause) -Copyright (c) 2013 Gabriel Gonzalez+Copyright (c) 2013 Gabriella Gonzalez All rights reserved. Redistribution and use in source and binary forms, with or without modification,@@ -68,7 +68,7 @@ list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -* Neither the name of Gabriel Gonzalez nor the names of other contributors may+* Neither the name of Gabriella Gonzalez nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
changelog.md view
@@ -1,3 +1,7 @@+# Version++* Export `SafeT` constructor+ # Version 2.3.1 * Remove `MonadFail` constraints introduced in version 2.3.0
pipes-safe.cabal view
@@ -1,15 +1,15 @@ Name: pipes-safe-Version: 2.3.4+Version: 2.3.5 Cabal-Version: >=1.10 Build-Type: Simple License: BSD3 License-File: LICENSE Extra-Source-Files: README.md changelog.md-Copyright: 2013, 2014 Gabriel Gonzalez-Author: Gabriel Gonzalez-Maintainer: Gabriel439@gmail.com+Copyright: 2013, 2014 Gabriella Gonzalez+Author: Gabriella Gonzalez+Maintainer: GenuineGabriella@gmail.com Tested-With: GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.1-Bug-Reports: https://github.com/Gabriel439/Haskell-Pipes-Safe-Library/issues+Bug-Reports: https://github.com/Gabriella439/Haskell-Pipes-Safe-Library/issues Synopsis: Safety for the pipes ecosystem Description: This package adds resource management and exception handling to the @pipes@@@ -32,18 +32,18 @@ Category: Control, Pipes, Error Handling Source-Repository head Type: git- Location: https://github.com/Gabriel439/Haskell-Pipes-Safe-Library+ Location: https://github.com/Gabriella439/Haskell-Pipes-Safe-Library Library Build-Depends:- base >= 4.14 && < 4.17,+ base >= 4.14 && < 4.19, containers >= 0.6.2.1 && < 0.7 , exceptions >= 0.10.4 && < 0.11,- mtl >= 2.2.2 && < 2.3 ,- transformers >= 0.5.6.2 && < 0.6 ,+ mtl >= 2.2.2 && < 2.4 ,+ transformers >= 0.5.6.2 && < 0.7 , transformers-base >= 0.4.4 && < 0.5 , monad-control >= 1.0.0.4 && < 1.1 ,- primitive >= 0.7.0.0 && < 0.8 ,+ primitive >= 0.7.0.0 && < 0.9 , pipes >= 4.3.10 && < 4.4 Exposed-Modules: Pipes.Safe,
src/Pipes/Safe.hs view
@@ -62,7 +62,7 @@ module Pipes.Safe ( -- * SafeT- SafeT+ SafeT(SafeT) , runSafeT , runSafeP @@ -80,6 +80,9 @@ , bracket_ , bracketOnError + -- * Internals+ , Env+ -- * Re-exports -- $reexports , module Control.Monad.Catch@@ -202,13 +205,28 @@ , _finalizers :: !(M.Map Integer (m ())) } +-- | Internal 'SafeT' read-write environment. Exported only so that it can be+-- passed around unmodified by users of the v'SafeT' constructor.+--+-- Warning: Using the 'Env' outside the corresponding 'SafeT' scope will+-- result in undefined behavior.+newtype Env m = Env (IORef (Maybe (Finalizers m)))+ {-| 'SafeT' is a monad transformer that extends the base monad with the ability to 'register' and 'release' finalizers. All unreleased finalizers are called at the end of the 'SafeT' block, even in the event of exceptions. -}-newtype SafeT m r = SafeT { unSafeT :: R.ReaderT (IORef (Maybe (Finalizers m))) m r }+newtype SafeT m r+ = -- | Constructor exported in case it's necessary for integrating 'SafeT'+ -- with other libraries. For example, implementing @mtl@-like+ -- Monad/Something/ instances will often require access to the 'SafeT'+ -- constructor.+ --+ -- Warning: Using the 'Env' outside the corresponding 'SafeT' scope will+ -- result in undefined behavior.+ SafeT (R.ReaderT (Env m) m r) deriving ( Functor , Applicative@@ -249,7 +267,7 @@ the end of the computation -} runSafeT :: (MonadMask m, MonadIO m) => SafeT m r -> m r-runSafeT m = C.bracket+runSafeT (SafeT m) = C.bracket (liftIO $ newIORef $! Just $! Finalizers 0 M.empty) (\ioref -> do mres <- liftIO $ atomicModifyIORef' ioref $ \val ->@@ -257,7 +275,7 @@ case mres of Nothing -> error "runSafeT's resources were freed by another" Just (Finalizers _ fs) -> mapM snd (M.toDescList fs) )- (R.runReaderT (unSafeT m))+ (R.runReaderT m . Env) {-# INLINABLE runSafeT #-} {-| Run 'SafeT' in the base monad, executing all unreleased finalizers at the@@ -304,7 +322,7 @@ liftBase = lift register io = do- ioref <- SafeT R.ask+ Env ioref <- SafeT R.ask liftIO $ do n <- atomicModifyIORef' ioref $ \val -> case val of@@ -314,7 +332,7 @@ return (ReleaseKey n) release key = do- ioref <- SafeT R.ask+ Env ioref <- SafeT R.ask liftIO $ atomicModifyIORef' ioref $ \val -> case val of Nothing -> error "release: SafeT block is closed"