1module Data.Streaming.Process.Internal 2 ( StreamingProcessHandle (..) 3 , InputSource (..) 4 , OutputSink (..) 5 ) where 6 7import Control.Concurrent.STM (TMVar) 8import System.Exit (ExitCode) 9import System.IO (Handle) 10import System.Process (ProcessHandle, StdStream (CreatePipe)) 11 12-- | Class for all things which can be used to provide standard input. 13-- 14-- Since 0.1.4 15class InputSource a where 16 isStdStream :: (Maybe Handle -> IO a, Maybe StdStream) 17instance InputSource Handle where 18 isStdStream = (\(Just h) -> return h, Just CreatePipe) 19 20-- | Class for all things which can be used to consume standard output or 21-- error. 22-- 23-- Since 0.1.4 24class OutputSink a where 25 osStdStream :: (Maybe Handle -> IO a, Maybe StdStream) 26instance OutputSink Handle where 27 osStdStream = (\(Just h) -> return h, Just CreatePipe) 28 29-- | Wraps up the standard @ProcessHandle@ to avoid the @waitForProcess@ 30-- deadlock. See the linked documentation from the module header for more 31-- information. 32-- 33-- Since 0.1.4 34data StreamingProcessHandle = StreamingProcessHandle 35 ProcessHandle 36 (TMVar ExitCode) 37 (IO ()) -- cleanup resources 38