packages feed

streaming-commons 0.1.6 → 0.1.7

raw patch · 4 files changed

+83/−3 lines, 4 files

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.1.7++`withCheckedProcess` added.+ ## 0.1.6  Provide `appCloseConnection` to get the underlying connection from an `AppData`.
Data/Streaming/Process.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveDataTypeable #-} -- | A full tutorial for this module is available on FP School of Haskell: -- <https://www.fpcomplete.com/user/snoyberg/library-documentation/data-conduit-process>. --@@ -22,6 +23,9 @@       -- * Type classes     , InputSource     , OutputSink+      -- * Checked processes+    , withCheckedProcess+    , ProcessExitedUnsuccessfully (..)       -- * Reexport     , module System.Process     ) where@@ -31,10 +35,12 @@ import           Control.Concurrent.STM          (STM, TMVar, atomically,                                                   newEmptyTMVar, putTMVar,                                                   readTMVar)+import           Control.Exception               (Exception, throwIO) import           Control.Monad.IO.Class          (MonadIO, liftIO) import           Data.Maybe                      (fromMaybe) import           Data.Streaming.Process.Internal-import           System.Exit                     (ExitCode)+import           Data.Typeable                   (Typeable)+import           System.Exit                     (ExitCode (ExitSuccess)) import           System.IO                       (hClose) import           System.Process @@ -150,3 +156,42 @@         <*> getStdout stdoutH         <*> getStderr stderrH         <*> return (StreamingProcessHandle ph ec)++-- | Indicates that a process exited with an non-success exit code.+--+-- Since 0.1.7+data ProcessExitedUnsuccessfully = ProcessExitedUnsuccessfully CreateProcess ExitCode+    deriving Typeable+instance Show ProcessExitedUnsuccessfully where+    show (ProcessExitedUnsuccessfully cp ec) = concat+        [ "Process exited with "+        , show ec+        , ": "+        , showCmdSpec (cmdspec cp)+        ]+      where+        showCmdSpec (ShellCommand str) = str+        showCmdSpec (RawCommand x xs) = unwords (x:xs)+instance Exception ProcessExitedUnsuccessfully++-- | Run a process and supply its streams to the given callback function. After+-- the callback completes, wait for the process to complete and check its exit+-- code. If the exit code is not a success, throw a+-- 'ProcessExitedUnsuccessfully'.+--+-- Since 0.1.7+withCheckedProcess :: ( InputSource stdin+                      , OutputSink stderr+                      , OutputSink stdout+                      , MonadIO m+                      )+                   => CreateProcess+                   -> (stdin -> stdout -> stderr -> m b)+                   -> m b+withCheckedProcess cp f = do+    (x, y, z, sph) <- streamingProcess cp+    res <- f x y z+    ec <- waitForStreamingProcess sph+    if ec == ExitSuccess+        then return res+        else liftIO $ throwIO $ ProcessExitedUnsuccessfully cp ec
+ README.md view
@@ -0,0 +1,30 @@+streaming-commons+=================++Common lower-level functions needed by various streaming data libraries.+Intended to be shared by libraries like conduit and pipes.++[![Build Status](https://travis-ci.org/fpco/streaming-commons.svg)](https://travis-ci.org/fpco/streaming-commons)++Dependencies+------------++One of the requirements of this package is to restrict ourselves to "core"+dependencies. The definition of core is still to be decided, but here's a+working start:++* *No* dependency on system libraries, beyond that which is required by other+  dependencies.+* Anything which ships with GHC. *However*, we must retain compatibility with+  versions of those packages going back to at least GHC 7.4, and preferably+  earlier.+* text, once again with backwards compatibility for versions included with+  legacy Haskell Platform. In other words, 0.11.2 support is required.+* network, support back to 2.3. We do *not* need to support the+  network/network-bytestring split.+* stm, preferably all the way back to 2.1.+* transformers++For debate:++* Other Haskell Platform packages, especially vector and attoparsec.
streaming-commons.cabal view
@@ -1,11 +1,11 @@ name:                streaming-commons-version:             0.1.6+version:             0.1.7 synopsis:            Common lower-level functions needed by various streaming data libraries description:         Provides low-dependency functionality commonly needed by various streaming data libraries, such as conduit and pipes. homepage:            https://github.com/fpco/streaming-commons license:             MIT license-file:        LICENSE-author:              Michael Snoyman, Gabriel Gonzalez+author:              Michael Snoyman maintainer:          michael@snoyman.com -- copyright:            category:            Data@@ -18,6 +18,7 @@     cbits/*.c     test/LICENSE.gz     ChangeLog.md+    README.md  library   exposed-modules:     Data.Streaming.Blaze