1{-# LANGUAGE CPP, FlexibleContexts, MultiParamTypeClasses #-}
2{-# OPTIONS_GHC -fno-warn-orphans #-}
3module System.Process.Text where
4
5#if !MIN_VERSION_base(4,8,0)
6import Control.Applicative ((<$>))
7#endif
8import Control.Monad
9import Data.ListLike.IO (hGetContents)
10import Data.Text (Text)
11import Prelude hiding (null)
12import System.Process
13import System.Process.Common
14import System.Exit (ExitCode)
15
16instance ProcessText Text Char
17
18-- | Like 'System.Process.readProcessWithExitCode', but using 'Text'
19instance ListLikeProcessIO Text Char where
20    forceOutput = return
21    readChunks h = (: []) <$> hGetContents h
22
23-- | Specialized version for backwards compatibility.
24readProcessWithExitCode
25    :: FilePath                  -- ^ command to run
26    -> [String]                  -- ^ any arguments
27    -> Text                      -- ^ standard input
28    -> IO (ExitCode, Text, Text) -- ^ exitcode, stdout, stderr
29readProcessWithExitCode = System.Process.Common.readProcessWithExitCode
30
31readCreateProcessWithExitCode
32    :: CreateProcess             -- ^ command and arguments to run
33    -> Text                      -- ^ standard input
34    -> IO (ExitCode, Text, Text) -- ^ exitcode, stdout, stderr
35readCreateProcessWithExitCode = System.Process.Common.readCreateProcessWithExitCode
36