Re: [Haskell-cafe] STM atomic blocks in IO functions

2012-01-14 Thread Ketil Malde
Bryan O'Sullivan b...@serpentine.com writes: The question is a simple one. Must all operations on a TVar happen within *the same* atomically block, or am I am I guaranteed thread safety if, say, I have a number of atomically blocks in an IO function. If you want successive operations to see

Re: [Haskell-cafe] STM atomic blocks in IO functions

2012-01-14 Thread Steffen Schuldenzucker
On 01/14/2012 03:55 PM, Ketil Malde wrote: Bryan O'Sullivanb...@serpentine.com writes: The question is a simple one. Must all operations on a TVar happen within *the same* atomically block, or am I am I guaranteed thread safety if, say, I have a number of atomically blocks in an IO function.

Re: [Haskell-cafe] STM atomic blocks in IO functions

2012-01-14 Thread Rob Stewart
On 14 January 2012 18:05, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: I think consistent state here means that you can be sure no other thread has modified a, say, TVar, within the current 'atomically' block. OK, well take a modified example, where I am wanting to call an IO

Re: [Haskell-cafe] STM atomic blocks in IO functions

2012-01-14 Thread Daniel Waterworth
On 14 January 2012 19:24, Rob Stewart robstewar...@googlemail.com wrote: On 14 January 2012 18:05, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: I think consistent state here means that you can be sure no other thread has modified a, say, TVar, within the current 'atomically'

Re: [Haskell-cafe] STM atomic blocks in IO functions

2012-01-14 Thread wren ng thornton
On 1/14/12 2:24 PM, Rob Stewart wrote: Are IO functions permissible in STM atomically blocks? They are not. The semantics of STM are that each transaction is retried until it succeeds, and that the number of times it is retried does not affect the program output. Thus, you can only do things

[Haskell-cafe] STM atomic blocks in IO functions

2012-01-13 Thread Rob Stewart
Hi, My question is regarding the correct us of STM in Haskell. I have put to together a simple example, which represents more verbose code in a library that I am writing. The question is a simple one. Must all operations on a TVar happen within *the same* atomically block, or am I am I

Re: [Haskell-cafe] STM atomic blocks in IO functions

2012-01-13 Thread Bryan O'Sullivan
On Fri, Jan 13, 2012 at 10:04 AM, Rob Stewart robstewar...@googlemail.comwrote: The question is a simple one. Must all operations on a TVar happen within *the same* atomically block, or am I am I guaranteed thread safety if, say, I have a number of atomically blocks in an IO function. If