darcs patch: add withFile and withBinaryFile (#966)

David Roundy droundy at darcs.net
Thu Oct 26 13:42:58 EDT 2006


On Thu, Oct 26, 2006 at 06:15:59PM +0100, Ross Paterson wrote:
> He's already been there:
> 
> http://www.haskell.org/pipermail/haskell/2006-January/017410.html

I yes, I saw that post, but didn't read it carefully, and didn't think of
it, but am sure it must have been lurking in the back of my mind suggesting
that this could be done.  Usually I find Oleg's solutions well nigh
incomprehensible, but in this case, it seems downright simple.  The only
catch is that you've got to use a new monad.  And I suppose there's a
possibility of confusing error messages.

I suppose, though, that this kind of change would best be part of a
complete refactoring of the IO monad (which is something I've been longing
to do--to break (almost?) all the IO functions into classes, so you could
write standard IO code that can run in other monads (e.g. a tarball-reading
monad, or a quickcheck fake-IO monad, or in darcs the SlurpMonad), or could
use it to statically enforce constraints (e.g. this bit of IO code doesn't
touch the network, doesn't write to disk, etc).  Not that I expect to have
time to do this any time soon, but it'd be beautiful... and we all know
that physicists (and I suppose computer scientists, too?) are suckers for
the beautiful.
-- 
David Roundy
Dept. of Physics
Oregon State University


More information about the Libraries mailing list