[Haskell-cafe] Functions with side-effects?
gregory.woodhouse at sbcglobal.net
Wed Dec 21 13:02:38 EST 2005
--- Wolfgang Jeltsch <wolfgang at jeltsch.net> wrote:
> > I think Phil Wadler said it best when he said that a monad is a
> > *computation*.
To be honest, I'm still struggling with the monad concept myself. Oh
sure, I can read the definition and it makes sense. But I'm still
missing that "aha!" moment when it all comes together.
> No, a value of type IO <something> is a computation. The type IO
> plus (>>=)
> plus return is a monad. So is  plus concatMap plus \x -> [x].
This may be totally off-base, but when I read this, it occured to me
that all I/O is basically a computation made to appear as if it is
something your program "does". You (or, rather the processor) don't
execute instructions to write "Hello" in same way as, say, adding 2 and
2. Rather, you add writing this string to a "to do" list and wait for a
driver to respond to an interrupt, pick up the request(s), and carry it
(them) out when control passes back the kernel.
Gregory Woodhouse <gregory.woodhouse at sbcglobal.net>
"Interaction is the mind-body problem of computing."
--Philip L. Wadler
More information about the Haskell-Cafe