
9 Feb
2009
9 Feb
'09
6:50 p.m.
Gregg Reynolds
But it can't be a function, since it is non-deterministic.
IMHO, if you assume IO a = World -> (World, a), then getChar is indeed a function and deterministic. It is, there are not w :: World such that getChar w != getChar. The fact that World is too big to be represented in Haskell and we use IO to simulate it is a different matter. With regard to your original question, I like to keep in mind that arrow composition in the Kleisli category (>>= in Haskell) is defined in terms of the monad's join :: m (m a) -> m a. Then, the question is, how many ways can you map an IO (IO a) to an IO a? You will find that you cannot ignore the inner (first) IO in order to obey monad laws. Regards, Emilio