packages feed

typed-process 0.1.1 → 0.2.0.0

raw patch · 4 files changed

+101/−95 lines, 4 filesdep −conduitdep −conduit-extradep −exceptionsdep ~basedep ~bytestringPVP ok

version bump matches the API change (PVP)

Dependencies removed: conduit, conduit-extra, exceptions, http-conduit

Dependency ranges changed: base, bytestring

API changes (from Hackage documentation)

- System.Process.Typed: createSink :: MonadIO m => StreamSpec STInput (ConduitM ByteString o m ())
- System.Process.Typed: createSource :: MonadIO m => StreamSpec STOutput (ConduitM i ByteString m ())
- System.Process.Typed: withProcess :: (MonadIO m, MonadMask m) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
+ System.Process.Typed: withProcess :: ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> IO a) -> IO a
- System.Process.Typed: withProcess_ :: (MonadIO m, MonadMask m) => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
+ System.Process.Typed: withProcess_ :: ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> IO a) -> IO a

Files

ChangeLog.md view
@@ -1,3 +1,8 @@+## 0.2.0.0++* Remove dependency on `conduit` and `conduit-extra`. Relevant code added to+  `Data.Conduit.Process.Typed` in `conduit-extra-1.2.1`.+ ## 0.1.1  * Introduce 'unsafeProcessHandle' function
src/System/Process/Typed.hs view
@@ -6,7 +6,15 @@ {-# LANGUAGE KindSignatures #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE ScopedTypeVariables #-}--- | Please see the README.md file for examples of using this API.+{-|+Please see the README.md file for examples of using this API.++__Applications using this library MUST use @-threaded@__ to link with the+threaded version of the RTS. 'spawnProcess' and the others spawn a Haskell+thread that blocks until the process exits. Without @-threaded@ this will block+/all/ the Haskell threads in your program until the spawned process exits.++-} module System.Process.Typed     ( -- * Types       ProcessConfig@@ -48,10 +56,6 @@     , useHandleOpen     , useHandleClose -      -- ** Conduit-    , createSink-    , createSource-       -- * Launch a process     , startProcess     , stopProcess@@ -86,11 +90,10 @@  import qualified Data.ByteString as S import Data.ByteString.Lazy.Internal (defaultChunkSize)-import Control.Exception (assert, evaluate, throwIO)+import Control.Exception (assert, evaluate, throwIO, Exception, SomeException, finally, bracket, onException, catch) import Control.Monad (void) import Control.Monad.IO.Class import qualified System.Process as P-import Control.Monad.Catch as C import Data.Typeable (Typeable) import System.IO (Handle, hClose) import Control.Concurrent.Async (async, cancel, waitCatch)@@ -99,9 +102,6 @@ import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy.Char8 as L8 import Data.String (IsString (fromString))-import Data.Conduit (ConduitM)-import qualified Data.Conduit as C-import qualified Data.Conduit.Binary as CB  #if MIN_VERSION_process(1, 4, 0) && !WINDOWS import System.Posix.Types (GroupID, UserID)@@ -538,22 +538,6 @@ useHandleClose :: Handle -> StreamSpec anyStreamType () useHandleClose h = mkStreamSpec (P.UseHandle h) $ \_ Nothing -> return ((), hClose h) --- | Provide input to a process by writing to a conduit.------ @since 0.1.0.0-createSink :: MonadIO m => StreamSpec 'STInput (ConduitM S.ByteString o m ())-createSink =-    (\h -> C.addCleanup (\_ -> liftIO $ hClose h) (CB.sinkHandle h))-    <$> createPipe---- | Read output from a process by read from a conduit.------ @since 0.1.0.0-createSource :: MonadIO m => StreamSpec 'STOutput (ConduitM i S.ByteString m ())-createSource =-    (\h -> C.addCleanup (\_ -> liftIO $ hClose h) (CB.sourceHandle h))-    <$> createPipe- -- | Launch a process based on the given 'ProcessConfig'. You should -- ensure that you close 'stopProcess' on the result. It's usually -- better to use one of the functions in this module which ensures@@ -645,21 +629,25 @@ -- | Use the bracket pattern to call 'startProcess' and ensure -- 'stopProcess' is called. --+-- In version 0.2.0.0, this function was monomorphized to @IO@ to+-- avoid a dependency on the exceptions package.+-- -- @since 0.1.0.0-withProcess :: (MonadIO m, C.MonadMask m)-            => ProcessConfig stdin stdout stderr-            -> (Process stdin stdout stderr -> m a)-            -> m a-withProcess config = C.bracket (startProcess config) stopProcess+withProcess :: ProcessConfig stdin stdout stderr+            -> (Process stdin stdout stderr -> IO a)+            -> IO a+withProcess config = bracket (startProcess config) stopProcess  -- | Same as 'withProcess', but also calls 'checkExitCode' --+-- In version 0.2.0.0, this function was monomorphized to @IO@ to+-- avoid a dependency on the exceptions package.+-- -- @since 0.1.0.0-withProcess_ :: (MonadIO m, C.MonadMask m)-             => ProcessConfig stdin stdout stderr-             -> (Process stdin stdout stderr -> m a)-             -> m a-withProcess_ config = C.bracket+withProcess_ :: ProcessConfig stdin stdout stderr+             -> (Process stdin stdout stderr -> IO a)+             -> IO a+withProcess_ config = bracket     (startProcess config)     (\p -> stopProcess p `finally` checkExitCode p) 
test/System/Process/TypedSpec.hs view
@@ -4,17 +4,15 @@  import System.Process.Typed import System.IO-import Data.Conduit-import qualified Data.Conduit.Binary as CB-import Network.HTTP.Simple import Control.Concurrent.Async (Concurrently (..))+import Control.Concurrent.STM (atomically) import Test.Hspec import System.Exit import System.IO.Temp import qualified Data.ByteString as S+import qualified Data.ByteString.Lazy as L import Data.String (IsString) import Data.Monoid ((<>))-import qualified Data.Conduit.List as CL import qualified Data.ByteString.Base64 as B64  #if !MIN_VERSION_base(4, 8, 0)@@ -76,16 +74,15 @@         runProcess_ "false" `shouldThrow` \ExitCodeException{} -> True      it "async" $ withSystemTempFile "httpbin" $ \fp h -> do-        bss <- withProcess (setStdin createSink $ setStdout createSource "base64") $ \p ->+        lbs <- withProcess (setStdin createPipe $ setStdout byteStringOutput "base64") $ \p ->             runConcurrently $-                Concurrently-                    ( httpSink "https://raw.githubusercontent.com/fpco/typed-process/master/README.md" $ \_res ->-                    CB.conduitHandle h .| getStdin p) *>-                Concurrently-                    ( runConduit-                    $ getStdout p-                   .| CL.consume)+                Concurrently (do+                  bs <- S.readFile "README.md"+                  S.hPut h bs+                  S.hPut (getStdin p) bs+                  hClose (getStdin p)) *>+                Concurrently (atomically $ getStdout p)         hClose h-        let encoded = S.filter (/= 10) $ S.concat bss+        let encoded = S.filter (/= 10) $ L.toStrict lbs         raw <- S.readFile fp         encoded `shouldBe` B64.encode raw
typed-process.cabal view
@@ -1,51 +1,67 @@-name:                typed-process-version:             0.1.1-synopsis:            Run external processes, with strong typing of streams-description:         Please see README.md-homepage:            https://haskell-lang.org/library/typed-process-license:             MIT-license-file:        LICENSE-author:              Michael Snoyman-maintainer:          michael@snoyman.com-category:            System-build-type:          Simple-extra-source-files:  README.md ChangeLog.md-cabal-version:       >=1.10+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 560e972d4c4e48105953a0dfdad3211ec5fd390979dba3f10e57fa6b2407aea7 -library-  hs-source-dirs:      src-  exposed-modules:     System.Process.Typed-  build-depends:       base >= 4.7 && < 5-                     , async-                     , bytestring-                     , conduit-                     , conduit-extra-                     , exceptions-                     , process >= 1.2-                     , stm-                     , transformers-  if os(windows)-    cpp-options:       -DWINDOWS-  default-language:    Haskell2010+name:           typed-process+version:        0.2.0.0+synopsis:       Run external processes, with strong typing of streams+description:    Please see the tutorial at <https://haskell-lang.org/library/typed-process>+category:       System+homepage:       https://haskell-lang.org/library/typed-process+bug-reports:    https://github.com/fpco/typed-process/issues+author:         Michael Snoyman+maintainer:     michael@snoyman.com+license:        MIT+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.10 -test-suite typed-process-test-  type:                exitcode-stdio-1.0-  hs-source-dirs:      test-  main-is:             Spec.hs-  other-modules:       System.Process.TypedSpec-  build-depends:       base-                     , async-                     , base64-bytestring-                     , bytestring-                     , conduit-                     , conduit-extra-                     , hspec-                     , http-conduit >= 2.1.10-                     , temporary-                     , typed-process-  ghc-options:         -threaded -rtsopts -with-rtsopts=-N-  default-language:    Haskell2010+extra-source-files:+    ChangeLog.md+    README.md  source-repository head-  type:     git+  type: git   location: https://github.com/fpco/typed-process++library+  hs-source-dirs:+      src+  build-depends:+      async+    , base >=4.7 && <5+    , bytestring+    , process >=1.2+    , stm+    , transformers+  if os(windows)+    cpp-options: -DWINDOWS+  exposed-modules:+      System.Process.Typed+  other-modules:+      Paths_typed_process+  default-language: Haskell2010++test-suite typed-process-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  hs-source-dirs:+      test+  ghc-options: -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      async+    , base >=4.7 && <5+    , base64-bytestring+    , bytestring+    , hspec+    , process >=1.2+    , stm+    , temporary+    , transformers+    , typed-process+  other-modules:+      System.Process.TypedSpec+      Paths_typed_process+  default-language: Haskell2010