On 08/12/2009 03:54, Bas van Dijk wrote:
Could not get to sleep tonight so I got up and hacked this together:

http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13782

Does something like this already exist on hackage:

If not, I may turn this into a package and upload it tomorrow.

Comments, criticism and patches are welcome.

regards,

Bas

I like this idea.

A small observation, though:

stdin :: ReadModes ioMode => Handle ioMode
stdin = Handle SIO.stdin

This allows writing to stdin by choosing ReadWriteMode as the ioMode. I think 
it would be better to have just
stdin :: Handle ReadMode

*HandleExplicitIOMode> hPutStrLn (stdin :: Handle ReadWriteMode) "This shouldn't 
typecheck!"
*** Exception: <stdin>: hPutStr: illegal operation (handle is not open for 
writing)

This also shows another reason for stdin, stdout and stderr to be monomorphic:

hGetLine stdin
<interactive>:1:0:
    Ambiguous type variable `ioMode' in the constraint:
      `ReadModes ioMode'
        arising from a use of `hGetLine' at <interactive>:1:0-13
    Probable fix: add a type signature that fixes these type variable(s)


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to