conduit-extra 1.1.10.1 → 1.1.11
raw patch · 3 files changed
+29/−1 lines, 3 filesdep ~exceptionsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: exceptions
API changes (from Hackage documentation)
+ Data.Conduit.Process: withCheckedProcessCleanup :: (InputSource stdin, OutputSink stderr, OutputSink stdout, MonadIO m, MonadMask m) => CreateProcess -> (stdin -> stdout -> stderr -> m b) -> m b
Files
- ChangeLog.md +4/−0
- Data/Conduit/Process.hs +23/−0
- conduit-extra.cabal +2/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.1.11++* `withCheckedProcessCleanup`+ ## 1.1.10.1 * Fix a leftovers bug in helperDecompress #254
Data/Conduit/Process.hs view
@@ -14,6 +14,7 @@ ( -- * Functions sourceCmdWithConsumer , sourceProcessWithConsumer+ , withCheckedProcessCleanup -- * Reexport , module Data.Streaming.Process ) where@@ -26,6 +27,7 @@ import Data.Conduit import Data.Conduit.Binary (sourceHandle, sinkHandle) import Data.ByteString (ByteString)+import Control.Monad.Catch (MonadMask, onException, throwM) instance (r ~ (), MonadIO m, i ~ ByteString) => InputSource (ConduitM i o m r) where isStdStream = (\(Just h) -> return $ sinkHandle h, Just CreatePipe)@@ -57,3 +59,24 @@ -- Since 1.1.2 sourceCmdWithConsumer :: MonadIO m => String -> Consumer ByteString m a -> m (ExitCode, a) sourceCmdWithConsumer cmd = sourceProcessWithConsumer (shell cmd)++-- | Same as 'withCheckedProcess', but kills the child process in the case of+-- an exception being thrown by the provided callback function.+withCheckedProcessCleanup+ :: ( InputSource stdin+ , OutputSink stderr+ , OutputSink stdout+ , MonadIO m+ , MonadMask m+ )+ => CreateProcess+ -> (stdin -> stdout -> stderr -> m b)+ -> m b+withCheckedProcessCleanup cp f = do+ (x, y, z, sph) <- streamingProcess cp+ res <- f x y z `onException`+ liftIO (terminateProcess (streamingProcessHandleRaw sph))+ ec <- waitForStreamingProcess sph+ if ec == ExitSuccess+ then return res+ else throwM $ ProcessExitedUnsuccessfully cp ec
conduit-extra.cabal view
@@ -1,5 +1,5 @@ Name: conduit-extra-Version: 1.1.10.1+Version: 1.1.11 Synopsis: Batteries included conduit: adapters for common libraries. Description: The conduit package itself maintains relative small dependencies. The purpose of this package is to collect commonly used utility functions wrapping other library dependencies, without depending on heavier-weight dependencies. The basic idea is that this package should only depend on haskell-platform packages and conduit.@@ -39,6 +39,7 @@ -- No version bounds necessary, since they're inherited -- from conduit. , bytestring+ , exceptions , monad-control , text , transformers