Phil writes:
> 
> > I'd actually prefer if stdin&stdout were not constants, but argv was ;)
> > Having operators just like getArgs for the standard handles 
> > 
> >   getStdin  :: IO Handle
> >   getStdout :: IO Handle
> >   getStderr :: IO Handle
> > 
> > would not prevent an implementation from providing useful redirection
> > operations like the following
> > 
> >    stdRedirect :: (Handle,Handle,Handle) -> IO a -> IO a
> > 
> > where the second argument is performed using a different standard
> > handle triple.
> 
> This set off a flury of mail, and I can't tell if the issue has
> yet been resolved or not.  Apologies if this messsage is now
> redundant, but as far as I can see no one addressed Sigbjorn's
> message in it's original terms.
> 

Well, my mind has been laid to rest over this, thanks to Fergus and
Lennart; to achieve the benefit of the above, you could for instance
just define a Handle as being:

   type Handle = IO PrimHandle

   stdout = getStdout
   stdin  = ...

and use stdout, stdin as before - no changes reqd, great :-)
(I was being too GHC implementation-centric when initially suggesting
the above)

> Sigbjorn,  Yes, your stdRedirect seems like a helpful operator.
> But it works just as well with stdin, stdout, and stderr as constants.
> For instance,
> 
>   stdRedirect stdout stdin stderr m
> 
> might swap the roles of stdin and stdout within m.
> 

I think it adds useful expressiveness too, but I'd like to have some
experience of using it before eventually begging for its inclusion
in the standard Haskell IO API.

>
> Cheers,  -- P
> 

--Sigbjorn




Reply via email to