[Haskell-cafe] Theoretical question: are side effects necessary?

Jeff Shaw shawjef3 at msu.edu
Sat Mar 17 05:58:12 CET 2012

> 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:

MVar a -> a -> IO () 

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 

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120317/629dbfb3/attachment.htm>

More information about the Haskell-Cafe mailing list