It is the third or the fourth time that somebody recently puts the
equivalence between the communication with the outer world, and "side
effects". I contest that very strongly, perhaps a TRUE guru might
instruct me.
I think there are three key concepts rumbling around in this discussion
that are related, but distinct: determinism, purity, and side effects.
An easy trap to fall into is the idea that determinism = purity, when
really they are not the same. There is a set of functions that are
deterministic, but not pure. An example is putMVar:
*putMVar*
<http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-MVar.html#v:putMVar>::
MVar a -> a -> IO ()
<http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-MVar.html#v:putMVar>
On the other hand, there are functions that are non-deterministic, but pure:
nondeterministicAndPure :: () -> MonadState Int Int
nondeterministicAndPure () = do
x <- get
return x
Then, there are functions that are both deterministic and pure, like
lookup, and functions that are neither deterministic, nor pure, like
takeMVar.
I'm thinking that side effects are really only necessary because Haskell
programs expect to mutate the state of a computer outside of the haskell
program. Perhaps if we had Haskell OS, everything could live in some
giant MonadState, and IO could be disposed of entirely.
Jeff
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe