
On Fri, May 16, 2008 at 02:34:48PM +0100, Neil Mitchell wrote:
- made it work on Windows, and the patch passes GHC's validate on both Windows and Linux.
Reminder: the deadline for discussion is 20 May (5 days).
Fully support. I think it could benefit from a slight clarification to the documentation in createProcess, to help pattern-match safety checking.
(aStdin,aStdout,aStderr,d) <- createProcess cp isJust aStdin == (std_in == CreatePipe)
(and ditto for the out and err)
If only we had type families already, then we could define -- These data constructors are exported data Inherit = Inherit data CreatePipe = CreatePipe data UseHandle = UseHandle Handle data NewHandle = NewHandle Handle -- This class is not exported! (so CreateProcess needn't worry about new -- instances sowing up) class StdStream s where type Out s isInherit :: s -> Bool isCreatePipe :: s -> Bool isHandle :: s -> Maybe Handle instance StdStream Inherit where type Out Inherit = () ... instance StdStream IsHandle where type Out IsHandle = () ... instance StdStream CreateProcess where type Out Inherit = NewHandle ... data CreateProcess sin sout serr = CreateProcess { cmdspec :: CmdSpec cwd :: (Maybe FilePath) env :: (Maybe [(String, String)]) std_in :: sin std_out :: sout std_err :: serr close_fds :: Bool } createProcess :: (StdStream sin, StdStream sout, StdStream serr) => CreateProcess sin sout serr -> IO (Out sin, Out sout, Out serr, ProcessHandle) Then we could have a static guarantee that we only try to peek at actually-created pipes. I suppose this is a bit heavy infrastructure just to avoid runtime checks for "Just", but in a few years (say, post Haskell'...) it'd be nice to have safer instances like this. David