[Haskell-cafe] Re: [Haskell] Top Level <-
jonathanccast at fastmail.fm
Wed Aug 27 12:12:42 EDT 2008
On Wed, 2008-08-27 at 11:53 +0100, Adrian Hey wrote:
> John Meacham wrote:
> > As with all design decisions, it is sometimes the right thing and
> > sometimes the wrong one. And sometimes the most expedient. (which,
> > occasionally, is a perfectly valid driving force behind a certain bit of
> > coding). However, I am fully convinced it is necessary. You don't even
> > have to look further than Haskell 98 to find a use in the Random module,
> > and Data.Unique _depends_ on the state being global for correctness.
> ..and of course there's stdin, stdout. That takes some explaining.
Not really. If you don't have buffered IO, then you just say
stdin = 0
stdout = 1
stderr = 2
If you need buffered IO, you just change your IO monad* to look like:
newtype NewIO alpha = NewIO (ReaderT (Map Fd Buffer) OldIO alpha)
Of course, if you do this, you can't go mixing IO with unique values
with RNG with mutable state with everything else under the sun anymore.
You might actually have to declare exactly what effects you need when
you give your function's type, now. Clearly, a horror we must avoid at
* I wonder why that name was chosen? The design doesn't seem to have
anything to do with IO, it's more of a `we have this in C so we want it
in Haskell too' monad.
More information about the Haskell-Cafe