typed-process 0.2.1.0 → 0.2.2.0
raw patch · 4 files changed
+81/−39 lines, 4 files
Files
- ChangeLog.md +4/−0
- README.md +28/−27
- src/System/Process/Typed.hs +39/−2
- typed-process.cabal +10/−10
ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.2.2.0++* Add inherit versions of setter functions+ ## 0.2.1.0 * Add `readProcessStdout`, `readProcessStdout_`, `readProcessStderr`, and `readProcessStderr_`
README.md view
@@ -23,7 +23,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.IO (hPutStr, hClose) import System.Process.Typed@@ -79,7 +79,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -107,7 +107,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -123,7 +123,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -138,8 +138,8 @@ ## Type parameters -Both `ProcessConfig` and `Process` each take three type parameters,-with the type of the standard input, output, and error streams for the+Both `ProcessConfig` and `Process` take three type parameters:+the types of the standard input, output, and error streams for the process. As you saw above, our default is `()` for each, and our default behavior is to inherit the streams from the parent process. This is why, when you run the previous programs, the `date`@@ -151,7 +151,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -183,7 +183,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -214,7 +214,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -228,7 +228,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -241,7 +241,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -259,7 +259,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.Exit (ExitCode)@@ -285,7 +285,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import Data.ByteString.Lazy (ByteString)@@ -306,15 +306,15 @@ from a process to a file. This is superior to the memory approach as it does not have the risk of using large amounts of memory, though it is more inconvenient. Together with the-[temporary library](https://www.stackage.org/package/temporary), we+[`UnliftIO.Temporary`](https://www.stackage.org/haddock/lts-10.2/unliftio-0.2.2.0/UnliftIO-Temporary.html), we can do some nice things: ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed-import System.IO.Temp (withSystemTempFile)+import UnliftIO.Temporary (withSystemTempFile) main :: IO () main = withSystemTempFile "date" $ \fp h -> do@@ -335,11 +335,11 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO (hClose)-import System.IO.Temp (withSystemTempFile)+import UnliftIO.Temporary (withSystemTempFile) import Control.Monad (replicateM_) main :: IO ()@@ -365,7 +365,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -377,7 +377,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -390,11 +390,11 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO-import System.IO.Temp (withSystemTempFile)+import UnliftIO.Temporary (withSystemTempFile) main :: IO () main = withSystemTempFile "input" $ \fp h -> do@@ -416,7 +416,7 @@ ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO@@ -443,13 +443,14 @@ ## Other settings We've so far only played with modifying streams, but there are a-number of other settings you can tweak. It's best to just look at the-API docs for all available functions. We'll give examples of the two-most common settings: the working directory and environment variables.+number of other settings you can tweak. It's best to just+[look at the API docs](https://www.stackage.org/package/typed-process)+for all available functions. We'll give examples of the two most+common settings: the working directory and environment variables. ```haskell #!/usr/bin/env stack--- stack --resolver lts-7.3 --install-ghc runghc --package typed-process+-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed
src/System/Process/Typed.hs view
@@ -32,7 +32,9 @@ , setStdout , setStderr , setWorkingDir+ , setWorkingDirInherit , setEnv+ , setEnvInherit , setCloseFds , setCreateGroup , setDelegateCtlc@@ -43,7 +45,9 @@ #endif #if MIN_VERSION_process(1, 4, 0) && !WINDOWS , setChildGroup+ , setChildGroupInherit , setChildUser+ , setChildUserInherit #endif -- * Stream specs@@ -336,6 +340,14 @@ -> ProcessConfig stdin stdout stderr setWorkingDir dir pc = pc { pcWorkingDir = Just dir } +-- | Inherit the working directory from the parent process.+--+-- @since 0.2.2.0+setWorkingDirInherit+ :: ProcessConfig stdin stdout stderr+ -> ProcessConfig stdin stdout stderr+setWorkingDirInherit pc = pc { pcWorkingDir = Nothing }+ -- | Set the environment variables of the child process. -- -- Default: current process's environment.@@ -346,6 +358,14 @@ -> ProcessConfig stdin stdout stderr setEnv env pc = pc { pcEnv = Just env } +-- | Inherit the environment variables from the parent process.+--+-- @since 0.2.2.0+setEnvInherit+ :: ProcessConfig stdin stdout stderr+ -> ProcessConfig stdin stdout stderr+setEnvInherit pc = pc { pcEnv = Nothing }+ -- | Should we close all file descriptors besides stdin, stdout, and -- stderr? See 'P.close_fds' for more information. --@@ -431,6 +451,14 @@ -> ProcessConfig stdin stdout stderr setChildGroup x pc = pc { pcChildGroup = Just x } +-- | Inherit the group from the parent process.+--+-- @since 0.2.2.0+setChildGroupInherit+ :: ProcessConfig stdin stdout stderr+ -> ProcessConfig stdin stdout stderr+setChildGroupInherit pc = pc { pcChildGroup = Nothing }+ -- | Set the child process's user ID with the POSIX @setuid@ syscall, -- does nothing on non-POSIX. See 'P.child_user'. --@@ -442,6 +470,14 @@ -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr setChildUser x pc = pc { pcChildUser = Just x }++-- | Inherit the user from the parent process.+--+-- @since 0.2.2.0+setChildUserInherit+ :: ProcessConfig stdin stdout stderr+ -> ProcessConfig stdin stdout stderr+setChildUserInherit pc = pc { pcChildUser = Nothing } #endif -- | Create a new 'StreamSpec' from the given 'P.StdStream' and a@@ -630,7 +666,7 @@ -> m () stopProcess = liftIO . pCleanup --- | Use the bracket pattern to call 'startProcess' and ensure+-- | Uses the bracket pattern to call 'startProcess' and ensures that -- 'stopProcess' is called. -- -- In version 0.2.0.0, this function was monomorphized to @IO@ to@@ -768,7 +804,8 @@ -> m ExitCode runProcess pc = liftIO $ withProcess pc waitExitCode --- | Same as 'runProcess', but ignores the 'ExitCode'.+-- | Same as 'runProcess', but instead of returning the+-- 'ExitCode', checks it with 'checkExitCode'. -- -- @since 0.1.0.0 runProcess_ :: MonadIO m
typed-process.cabal view
@@ -1,11 +1,11 @@--- This file has been generated from package.yaml by hpack version 0.20.0.+-- This file has been generated from package.yaml by hpack version 0.21.2. -- -- see: https://github.com/sol/hpack ----- hash: e72374c0c785376b03398fc434d91290fe62139cf33b5a9645e9ab494318f219+-- hash: 11068332a1f3de188a488a22fdb0b1bc49f70ccc1dd04c322123278d6d6124e3 name: typed-process-version: 0.2.1.0+version: 0.2.2.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@@ -27,6 +27,10 @@ location: https://github.com/fpco/typed-process library+ exposed-modules:+ System.Process.Typed+ other-modules:+ Paths_typed_process hs-source-dirs: src build-depends:@@ -38,15 +42,14 @@ , 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+ other-modules:+ System.Process.TypedSpec+ Paths_typed_process hs-source-dirs: test ghc-options: -threaded -rtsopts -with-rtsopts=-N@@ -61,7 +64,4 @@ , temporary , transformers , typed-process- other-modules:- System.Process.TypedSpec- Paths_typed_process default-language: Haskell2010