{-# LANGUAGE CPP, MultiParamTypeClasses #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module System.Process.Chars where
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative ((<$>))
#endif
import Control.DeepSeq (force)
import qualified Control.Exception as C (evaluate)
import Data.ListLike.IO (hGetContents)
import Data.Text.Lazy (fromStrict, toChunks)
import Data.ListLike.Chars (Chars(..))
import Prelude hiding (null)
import System.Process
import System.Process.Common
import System.Exit (ExitCode)
instance ListLikeProcessIO Chars Char where
forceOutput :: Chars -> IO Chars
forceOutput = Chars -> IO Chars
forall a. a -> IO a
C.evaluate (Chars -> IO Chars) -> (Chars -> Chars) -> Chars -> IO Chars
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Chars -> Chars
forall a. NFData a => a -> a
force
readChunks :: Handle -> IO [Chars]
readChunks Handle
h = ((Text -> Chars) -> [Text] -> [Chars]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> Chars
T (Text -> Chars) -> (Text -> Text) -> Text -> Chars
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
fromStrict) ([Text] -> [Chars]) -> (Text -> [Text]) -> Text -> [Chars]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text]
toChunks) (Text -> [Chars]) -> IO Text -> IO [Chars]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Handle -> IO Text
forall full item. ListLikeIO full item => Handle -> IO full
hGetContents Handle
h
readProcessWithExitCode
:: FilePath
-> [String]
-> Chars
-> IO (ExitCode, Chars, Chars)
readProcessWithExitCode :: FilePath -> [FilePath] -> Chars -> IO (ExitCode, Chars, Chars)
readProcessWithExitCode = FilePath -> [FilePath] -> Chars -> IO (ExitCode, Chars, Chars)
forall text char.
ListLikeProcessIO text char =>
FilePath -> [FilePath] -> text -> IO (ExitCode, text, text)
System.Process.Common.readProcessWithExitCode
readCreateProcessWithExitCode
:: CreateProcess
-> Chars
-> IO (ExitCode, Chars, Chars)
readCreateProcessWithExitCode :: CreateProcess -> Chars -> IO (ExitCode, Chars, Chars)
readCreateProcessWithExitCode = CreateProcess -> Chars -> IO (ExitCode, Chars, Chars)
forall maker text char.
(ProcessMaker maker, ListLikeProcessIO text char) =>
maker -> text -> IO (ExitCode, text, text)
System.Process.Common.readCreateProcessWithExitCode