pipes-shell 0.1.3 → 0.1.4
raw patch · 2 files changed
+26/−22 lines, 2 filesdep ~basedep ~hspecdep ~text
Dependency ranges changed: base, hspec, text
Files
- pipes-shell.cabal +9/−9
- src/Pipes/Shell.hs +17/−13
pipes-shell.cabal view
@@ -4,7 +4,7 @@ -- The name of the package. name: pipes-shell -version: 0.1.3+version: 0.1.4 -- A short (one-line) description of the package. synopsis: Create proper Pipes from System.Process@@ -27,7 +27,7 @@ -- patches. maintainer: kartoffelbrei.mit.muskatnuss@gmail.com -bug-reports: https://github.com/kbrei/pipes-shell/issues+bug-reports: https://bitbucket.org/kbrei/pipes-shell/issues -- A copyright notice.@@ -46,7 +46,7 @@ source-repository head type: git- location: git://github.com/kbrei/pipes-shell.git+ location: git://kbrei@bitbucket.org/kbrei/pipes-shell.git library -- Modules exported by the library.@@ -60,7 +60,7 @@ -- Other library packages from which modules are imported. build-depends: async >= 2.0.1.0 && <2.1- , base >=4.5 && <4.8+ , base >=4.5 && <4.9 , bytestring >= 0.10.0.2 && <0.11 , pipes >= 4.0.1 && <5 , pipes-bytestring >= 1.0.1 && <3@@ -68,12 +68,12 @@ , process >=1.2 && <1.3 , stm >=2.4 && <2.5 , stm-chans >= 3.0.0 && <3.1- , text >= 0.11.3.0 && <1.2+ , text >= 0.11.3.0 && <1.3 -- Directories containing source files. hs-source-dirs: src - ghc-options: -Wall -O2+ ghc-options: -Wall -- Base language which the package is written in. default-language: Haskell2010@@ -90,17 +90,17 @@ -- Other library packages from which modules are imported. build-depends: async >= 2.0.1.0 && <2.1- , base >=4.5 && <4.8+ , base >=4.5 && <4.9 , bytestring >= 0.10.0.2 && <0.11 , directory >= 1.2.1.0- , hspec >= 1.12.1+ , hspec >= 2.2.0 , pipes >= 4.0.1 && <5 , pipes-bytestring >= 1.0.1 && <3 , pipes-safe >= 2.0.1 && <3 , process >=1.2 && <1.3 , stm >=2.4 && <2.5 , stm-chans >= 3.0.0 && <3.1- , text >= 0.11.3.0 && <1.2+ , text >= 0.11.3.0 && <1.3 -- Directories containing source files. hs-source-dirs: src, test
src/Pipes/Shell.hs view
@@ -10,8 +10,13 @@ -- use the pipes-bytestring and the upcoming pipes-text machinery. -- Note that exit code handling is not yet implemented. ----- All code examples in this module assume following qualified imports:--- Pipes.Prelude as P, Pipes.ByteString as PBS, Data.ByteString.Char8 as BSC+-- All code examples in this module assume the following imports:+--+-- @+-- import Pipes.Prelude as P+-- import Pipes.ByteString as PBS+-- import Data.ByteString.Char8 as BSC+-- @ module Pipes.Shell (@@ -45,16 +50,15 @@ import Control.Concurrent.STM.TMChan import qualified System.IO as IO import System.Process-import Debug.Trace import qualified Data.ByteString as BS -- Fancy overloads --- | An ad-hoc typeclass to get the varadic arguments and DWIM behavoir of 'cmdEnv'+-- | An ad-hoc typeclass to get the variadic arguments and DWIM behavior of 'cmdEnv' class Cmd cmd where -- | Like 'pipeCmdEnv', 'producerCmdEnv' or 'consumerCmdEnv'- -- depending on the context. It also supports varadic arguments.+ -- depending on the context. It also supports variadic arguments. -- -- Examples: --@@ -74,7 +78,7 @@ -- <a new file with "aaa" in it> cmdEnv :: Maybe [(String,String)] -> String -> cmd - -- | Like 'cmdEnv' but doesn't set enviorment varaibles+ -- | Like 'cmdEnv' but doesn't set environment variables cmd :: Cmd cmd => String -> cmd cmd = cmdEnv Nothing @@ -101,12 +105,12 @@ cmdEnv = consumerCmdEnv --- | An ad-hoc typeclass to get the varadic arguments and DWIM behavoir of 'cmd''.+-- | An ad-hoc typeclass to get the variadic arguments and DWIM behavoir of 'cmd''. -- This class is seperate from 'Cmd' to make the return types work out. class Cmd' cmd where -- | Like 'cmd' but uses 'ignoreErr' automatically. -- So it's like 'pipeCmd'', 'producerCmd'' or 'consumerCmd' depending on context.- -- It supports the same style of varadic arguments as 'cmd'+ -- It supports the same style of variadic arguments as 'cmd' cmd' :: String -> cmd instance Cmd' cmd => Cmd' (String -> cmd) where@@ -141,7 +145,7 @@ pipeCmdEnv env' cmdStr = bracket (aquirePipe env' cmdStr) releasePipe $ \(stdin, stdout, stderr) -> do - chan <- liftIO $ newTMChanIO+ chan <- liftIO newTMChanIO _ <- liftIO . forkIO $ handlesToChan stdout stderr chan @@ -180,7 +184,7 @@ atomically $ closeTMChan chan --- | Like 'pipeCmdEnv' but doesn't set enviorment varaibles+-- | Like 'pipeCmdEnv' but doesn't set environment variables pipeCmd :: MonadSafe m => String -> Pipe (Maybe BS.ByteString) (Either BS.ByteString BS.ByteString) m ()@@ -201,7 +205,7 @@ Producer (Either BS.ByteString BS.ByteString) m () producerCmdEnv env' cmdStr = yield Nothing >-> pipeCmdEnv env' cmdStr --- | Like 'producerCmdEnv' but doesn't set enviorment varaibles+-- | Like 'producerCmdEnv' but doesn't set environment variables producerCmd :: MonadSafe m => String -> Producer (Either BS.ByteString BS.ByteString) m ()@@ -222,7 +226,7 @@ Consumer (Maybe BS.ByteString) m () consumerCmdEnv env' cmdStr = pipeCmdEnv env' cmdStr >-> void await --- | Like 'consumerCmdEnv' but doesn't set enviorment varaibles+-- | Like 'consumerCmdEnv' but doesn't set environment variables consumerCmd :: MonadSafe m => String -> Consumer (Maybe BS.ByteString) m ()@@ -246,7 +250,7 @@ infixl 7 >?> -- | Mark the end of a pipe.--- It wraps all values in a 'Just' and yields *one* 'Nothing'+-- It wraps all values in a 'Just' and yields __one__ 'Nothing' -- after the upstream pipe finished. markEnd :: Monad m => Proxy a' a b' b m r ->