Re: [Haskell-cafe] Why no IO transformer monad?

Udo Stenzel wrote:
Keean Schupke
schrieb am 20.12.04 14:20:54: Perhaps you would care to explain this then?
Damn, I read a pair parens in there where there was none. The result still stands as is: no transformer version of IO is possible.
But is that beacuse it really isn't (theoretically) possible, or just not possible to write in Haskell (because it would involve new primitives)? Surely if IO is (ST RealWorld a) then (StateT RealWorld m a) is more or less the right thing? Keean.

On Mon, Dec 20, 2004 at 02:16:52PM +0000, Keean Schupke wrote:
But is that beacuse it really isn't (theoretically) possible, or just not possible to write in Haskell (because it would involve new primitives)?
Surely if IO is (ST RealWorld a) then (StateT RealWorld m a) is more or less the right thing?
Sure, you only need to implement one primitive - world duplication ;) Consider m = []: Prelude Control.Monad.State> runStateT (do x <- lift [1,2,3]; put x) 0 [((),1),((),2),((),3)] Prelude Control.Monad.State> runIOT (do x <- lift [1,2,3]; print x) 0 hmmm? Best regards, Tomasz

On Mon, Dec 20, 2004 at 02:16:52PM +0000, Keean Schupke wrote:
Surely if IO is (ST RealWorld a) then (StateT RealWorld m a) is more or less the right thing?
But IO is not ST RealWorld (even if GHC pretends it is): other users of the world are not waiting for the new world produced by your Haskell program. IO is more accurately modelled by a resumption monad, cf http://www.haskell.org/pipermail/haskell-cafe/2003-August/004892.html That suggests a possible monad transformer: data IOT m a = Return a | Invoke (m (SysCall (IOT m a))) but with no way to define runIOT :: Monad m => IOT m a -> IO (...), it's not much use.

Ross Paterson wrote: On the haskell list it has almost been decided that (ST RealWorld a) and (IO a) _should_ merge and become the same thing. Keean.
On Mon, Dec 20, 2004 at 02:16:52PM +0000, Keean Schupke wrote:
Surely if IO is (ST RealWorld a) then (StateT RealWorld m a) is more or less the right thing?
But IO is not ST RealWorld (even if GHC pretends it is): other users of the world are not waiting for the new world produced by your Haskell program.
IO is more accurately modelled by a resumption monad, cf
http://www.haskell.org/pipermail/haskell-cafe/2003-August/004892.html
That suggests a possible monad transformer:
data IOT m a = Return a | Invoke (m (SysCall (IOT m a)))
but with no way to define runIOT :: Monad m => IOT m a -> IO (...), it's not much use.

Ross Paterson wrote:
But IO is not ST RealWorld (even if GHC pretends it is): other users of the world are not waiting for the new world produced by your Haskell program.
They're *part* of the world. IO = State RealWorld makes sense if you think of RealWorld as encapsulating the entire state of the universe, including "other users". The only trouble is that concurrent processes end up containing each other. I'm not entirely convinced that this can't be solved with some sort of fixed-point trick. -- Ben
participants (4)
-
Ben Rudiak-Gould
-
Keean Schupke
-
Ross Paterson
-
Tomasz Zielonka