{- | IO into a pair of Haskell handles, like the ones created with stdin and stdout of a forked process. -} module System.IO.Uniform.HandlePair ( HandlePair, fromHandles ) where import System.IO (Handle, hClose) import System.IO.Uniform import qualified Data.ByteString as BS {- | A pair of handles, the first for input, and the second for output. -} data HandlePair = HandlePair Handle Handle {- | > fromHandles inputHandler outputHandler Creates a uniform io target from a pair of handlers. -} fromHandles :: Handle -> Handle -> HandlePair fromHandles = HandlePair -- | UniformIO that reads from stdin and writes to stdout. instance UniformIO HandlePair where uRead (HandlePair i _) = BS.hGetSome i uPut (HandlePair _ o) = BS.hPut o uClose (HandlePair i o) = do hClose i hClose o startTls _ = return isSecure _ = True