
Andre, I can't work out how it should be done. The way I see it, the StateIO monad should have four functions associated with it. 1/ update - a function to update the state 2/ retrieve - a function to retrieve the state from the monad These two are inherited from the standard State monad 3/ input - make a character from stndIn available to the state transformation functions 4/ output - send the state of the monad after a certain set of transformations to stndOut I've managed to write functions 1-3 but not 4. Here's my work so far.I'm not really sure if this is on the right track. Tom On Thu, 2002-01-24 at 14:32, Andre W B Furtado wrote:
Hi, I have the same problem. Did anyone answered your question?
Thanks, -- Andre
----- Original Message ----- From: Tom Bevan
To: Haskell Cafe List Sent: Wednesday, January 23, 2002 4:29 AM Subject: Monad composition Hi all,
I'm writing a programme which requires IO actions to be interleaved with operations on a State monad. From what I can work out, this means that the IO Monad and the StateTransformation monad need to be composed into a single highr order monad. Does anyone have any references or pointers on how this should be done?
Tom
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Well, it's also possible to interchange data between these two monads by:
unsafeIOToST :: IO a -> ST s a
stToIO :: ST s a -> IO a
Can anyone tell the possible problems related to
unsafeIOToST?
^^^^^^
-- Andre
----- Original Message -----
From: Tom Bevan
Andre,
I can't work out how it should be done. The way I see it, the StateIO monad should have four functions associated with it. 1/ update - a function to update the state 2/ retrieve - a function to retrieve the state from the monad These two are inherited from the standard State monad 3/ input - make a character from stndIn available to the state transformation functions 4/ output - send the state of the monad after a certain set of transformations to stndOut
I've managed to write functions 1-3 but not 4.
Here's my work so far.I'm not really sure if this is on the right track.
Tom
On Thu, 2002-01-24 at 14:32, Andre W B Furtado wrote:
Hi, I have the same problem. Did anyone answered your question?
Thanks, -- Andre
----- Original Message ----- From: Tom Bevan
To: Haskell Cafe List Sent: Wednesday, January 23, 2002 4:29 AM Subject: Monad composition Hi all,
I'm writing a programme which requires IO actions to be interleaved
with
operations on a State monad. From what I can work out, this means that the IO Monad and the StateTransformation monad need to be composed into a single highr order monad. Does anyone have any references or pointers on how this should be done?
Tom
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Andre W B Furtado wrote:
Well, it's also possible to interchange data between these two monads by:
unsafeIOToST :: IO a -> ST s a stToIO :: ST s a -> IO a
Can anyone tell the possible problems related to unsafeIOToST? ^^^^^^
Probably in the same manner as with unsafePerformIO: it can break referential transparency. changeFile fileName = unsafePerformIO (writeFile fileName "Hello, world") fileContents fileName = unsafePerformIO (readFile fileName) Now, if there is a call to changeFile between two calls to fileContents with the same filename (assumed that the file didn't contain the text "Hello, world") the function returns different answers in exactly syntactic identical calls. Thus, referential transparency is broken. Rijk-Jan van Haaften
participants (3)
-
Andre W B Furtado
-
Rijk-Jan van Haaften
-
Tom Bevan