Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-29 Thread Sterling Clover
Clojure has a commute operator whose semantics seem appropriate to your concerns: http://clojure.org/refs http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/commute Commute in haskell would be roughly :: TVar a - (a - a) - STM a. The TVar touched by commute does not get

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-29 Thread Arie Middelkoop
Hi Tom, You wrote that you are interested in the programming experience with relaxed atomicity. What you are asking for are the ideas behind Twilight STM, written in these papers: http://proglang.informatik.uni-freiburg.de/projects/syncstm/techreport2010twilight.pdf (brief summary of the

[Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Tom Hawkins
Has anyone in the STM community considered the ability to read a TVar, such that it would allow the transaction to complete even if the TVar was modified by another transaction? (I am assuming this is not how STM works by default.) For example: looselyReadTVar :: TVar a - STM a Atom [1] has

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Peter Robinson
On 28 September 2010 15:35, Tom Hawkins tomahawk...@gmail.com wrote: Has anyone in the STM community considered the ability to read a TVar, such that it would allow the transaction to complete even if the TVar was modified by another transaction? Maybe something like this: (Pasted from

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread bieniusa
Hi Tom, you can do this with Twilight STM. I recently uploaded the first version on hackage[1]. The next version including a better algorithm and examples is about to be released in a few days. Twilight STM features include tagging of variables and fine-grained conflict detection, flexible

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Felipe Lessa
On Tue, Sep 28, 2010 at 10:41 AM, Peter Robinson thaldy...@gmail.com wrote: readTVarIO :: TVar a - IO a One needs to know if it is ok to wrap this IO action into an STM action. For example, data I a = I a looselyReadTVar :: TVar a - STM a looselyReadTVar tvar = let v = unsafePerformIO

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Antoine Latter
On Tue, Sep 28, 2010 at 8:54 AM, Felipe Lessa felipe.le...@gmail.com wrote: On Tue, Sep 28, 2010 at 10:41 AM, Peter Robinson thaldy...@gmail.com wrote: readTVarIO :: TVar a - IO a One needs to know if it is ok to wrap this IO action into an STM action.  For example, data I a = I a

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Felipe Lessa
On Tue, Sep 28, 2010 at 11:01 AM, Antoine Latter aslat...@gmail.com wrote: Isn't there an 'unsafeIOToSTM' function somewhere? Something like: unsafeIOToSTM (IO k) = STM k Then you might not need the case statement. I thought there was, but I couldn't find it in the 'stm' package [1], using

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Antoine Latter
On Tue, Sep 28, 2010 at 9:05 AM, Felipe Lessa felipe.le...@gmail.com wrote: On Tue, Sep 28, 2010 at 11:01 AM, Antoine Latter aslat...@gmail.com wrote: Isn't there an 'unsafeIOToSTM' function somewhere? Something like: unsafeIOToSTM (IO k) = STM k Then you might not need the case statement.

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Tom Hawkins
Thanks for the responses, but I think I should explain a bit more. I'm not interested in being able to read the live value of a TVar at any arbitrary time (via. unsafeIOToSTM). But rather I would like looslyReadTVar to have exactly the same semantics as readTVar, except that the STM runtime would

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Serguey Zefirov
2010/9/29 Tom Hawkins tomahawk...@gmail.com: In the embedded domain, this could be a fault monitor that reads a bunch of constantly changing sensors. I think that sensor reading belongs to IO, not STM. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Tom Hawkins
On Tue, Sep 28, 2010 at 6:44 PM, Serguey Zefirov sergu...@gmail.com wrote: 2010/9/29 Tom Hawkins tomahawk...@gmail.com: In the embedded domain, this could be a fault monitor that reads a bunch of constantly changing sensors. I think that sensor reading belongs to IO, not STM. Sensors would

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Brandon Moore
On Sep 28, 2010, at 6:36 PM, Tom Hawkins tomahawk...@gmail.com wrote: Thanks for the responses, but I think I should explain a bit more. I'm not interested in being able to read the live value of a TVar at any arbitrary time (via. unsafeIOToSTM). But rather I would like looslyReadTVar to have

Re: [Haskell-cafe] Relaxing atomicity of STM transactions

2010-09-28 Thread Antoine Latter
On Tue, Sep 28, 2010 at 9:19 PM, Brandon Moore brandon_m_mo...@yahoo.com wrote: On Sep 28, 2010, at 6:36 PM, Tom Hawkins tomahawk...@gmail.com wrote: Thanks for the responses, but I think I should explain a bit more. I'm not interested in being able to read the live value of a TVar at any