[Haskell-cafe] question about STM and IO

Ricardo Herrmann rherrmann at gmail.com
Thu Feb 14 11:59:08 EST 2008



Stephan Friedrichs-2 wrote:
> 
> 
> it's unsafe to perform IO inside of a transaction as it can't be undone, 
> when rolling it back. I guess, unsafeIOToSTM has been designed in order 
> to allow us to inject debugging output into a transaction, but you 
> really shouldn't use it to perform "real" IO (like writing files, etc.).
> 
> 

Simon Peyton Jones provides a good example of this in
http://research.microsoft.com/~simonpj/papers/stm/beautiful.pdf



> atomically (do { x <- readTVar xv
>                     ; y <- readTVar yv
>                     ; if x>y then launchMissiles
>                                else return () })
> 
> where launchMissiles :: IO () causes serious international side-effects.
> 

;-)

--
Ricardo Guimarães Herrmann
"There are only two industries that refer to their customers as 'users'" --
Edward Tufte
-- 
View this message in context: http://www.nabble.com/question-about-STM-and-IO-tp15439579p15481669.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list