Roughly speaking, I'm in need of a monad (say MyIO) that interprets the following code
f :: MyIO () f = do action1 action2 action3 ... return ()
as applying action1 to g, then action2 to the SAME g (not the result of action1) and so on... Of course, this "g" will be specified when starting the monad (something like "runMyIO g"). Does this "composition monad" already exist? If no, can anyone give me some hints to create my own? Thanks a lot -- Andre
I'm not sure exactly what you mean. Say I have something like that, then what's the difference between saying: f = do { action1; action2; action3 } and simply f = do action3 ? If the result of each of the actions is ignored for the following ones, why do we need to do this monadically? -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume On Mon, 18 Feb 2002, Andre W B Furtado wrote:
Roughly speaking, I'm in need of a monad (say MyIO) that interprets the following code
f :: MyIO () f = do action1 action2 action3 ... return ()
as applying action1 to g, then action2 to the SAME g (not the result of action1) and so on...
Of course, this "g" will be specified when starting the monad (something like "runMyIO g"). Does this "composition monad" already exist? If no, can anyone give me some hints to create my own?
Thanks a lot -- Andre
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Hal Daume III wrote:
I'm not sure exactly what you mean. Say I have something like that, then what's the difference between saying:
f = do { action1; action2; action3 }
and simply
f = do action3
?
If the result of each of the actions is ignored for the following ones, why do we need to do this monadically?
If g is an IORef, for example, action1 can modify the content of this IORef, but the reference itself is still the same. That's why I'd like to use the SAME g to all actions, although the content of g will be changed. -- Andre
Hal Daume III wrote:
I'm not sure exactly what you mean. Say I have something like that, then what's the difference between saying:
f = do { action1; action2; action3 }
and simply
f = do action3
?
If the result of each of the actions is ignored for the following ones, why do we need to do this monadically?
If g is an IORef, for example, action1 can modify the content of this IORef, but the reference itself is still the same. That's why I'd like to use the SAME g to all actions, although the content of g will be changed. -- Andre
Andre W B Furtado writes: | Roughly speaking, I'm in need of a monad (say MyIO) that interprets the | following code | | >f :: MyIO () | >f = do | > action1 | > action2 | > action3 | > ... | > return () | | | as applying action1 to g, then action2 to the SAME g (not the result of | action1) and so on... | | Of course, this "g" will be specified when starting the monad (something | like "runMyIO g"). Does this "composition monad" already exist? If no, can | anyone give me some hints to create my own? I think it's called a reader monad or an environment monad. Here's a fairly simple version: instance Monad ((->) env) where return x = \env -> x m >>= f = \env -> f (m env) env
participants (3)
-
Andre W B Furtado -
Hal Daume III -
Tom Pledger