[Haskell-cafe] Re: Handles with their IOMode in their type

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Wed Dec 9 21:00:00 EST 2009

On Dec 9, 2009, at 16:51 , Bas van Dijk wrote:
> I will change the types to:
> stdin :: Handle ReadMode
> stdout :: Handle WriteMode
> stderr :: Handle WriteMode
> Or are there scenarios where people want to write to stdin or read
> from stdout or stderr?

These situations *do* come up; the controlling terminal for a program  
is open read/write on all 3 file descriptors initially, ands programs  
like more/less/pg rely on this and do their I/O on stdout.   
Additionally, on *BSD pipes are actually socketpairs and therefore  
bidirectional, and a small number of programs rely on this.

But I would not do that by default, just expose a way for programs to  
make it so if they wish.

(Hm, just discovered that the System.Posix.IO wrapper for fcntl() does  
*not* expose the part of the result of F_GETFL that reports the open  
mode.  Boo hiss.)

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091209/082a52e1/PGP.bin

More information about the Haskell-Cafe mailing list