Post by Raffael CavallaroPost by Paul RubinI could say that traditional effectful computation, in whatever
language, is already done in a monad.
You could certainly say it, but it wouldn't be true. Your claim is
rather like saying that everyone who has a traditional Thanksgiving
dinner really craves Tofurky. Haskell is forced to make "effectful
computation" an explicit monad because, having denied itself side
effects, it had to add them back to the language so it could do useful
things. In a "tradtional effectful" language, these obviously useful
features were never eschewed in the first place, so there was no need
to jump through category theory hoops to get them back.
That pure functional languages conceptualize side effects as monads is
just reflection of their narrow view of computation, not a reflection
of the inherent nature of side effects. It is perfectly legitimate (in
fact, it is the human cognitive norm) to conceptualize the world as
inherently stateful and constantly mutating. You only reach for monads
when you insist that the world (or all computation) is a set of
functions returning values.
People love to use metaphors in such discussions. I doubt that it's
useful in any way. Let's discuss facts instead.
Firstly monads are not an indirection. Expressing side effects or state
monadically could hardly be any more direct. You have state, you can
'get' it, use it, 'modify' it and/or 'put' it back. The same with IO,
just that you have no 'get' function, because the state of the universe
has no distinct value in memory. Instead you have a bunch of functions
like 'putStr', 'hGetLine', 'connect', etc., which modify the universe
state.
What's wrong with this? It's not more to type than in C, in fact it's
less to type in most cases and even more intuitive to read. What could
be more intuitive than
forever (putStrLn "Hello world!")
for an endless loop printing a line repeatedly? It's just that people
who don't like monads either never used them (properly) or never made
efforts to understand them. Evidence for this comes from the frequent
but wrong claim that monads are there to "bring back" effectful
computation. Monads are universal tools for many things and show their
true power, as soon as you start combining them through monad
transformers.
However, this post is probably pointless anyway. Most people on Usenet
are totally obstinate. I recommend you to try out Haskell for more than
an hour. After all I was a convinced C programmer a few years ago, so
it's not that I'm so fond of Haskell because it's the only thing I know.
And that's about all I can say at this point.
Greets,
Ertugrul.
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://blog.ertes.de/