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 unde

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

2010-09-28 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 m

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 wrote: > > > On Sep 28, 2010, at 6:36 PM, Tom Hawkins 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

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

2010-09-28 Thread Brandon Moore
On Sep 28, 2010, at 6:36 PM, Tom Hawkins 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 exactly the same seman

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 wrote: > 2010/9/29 Tom Hawkins : >> 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 be transfered from IO to TVars v

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

2010-09-28 Thread Serguey Zefirov
2010/9/29 Tom Hawkins : > 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 Haskell-Cafe@haskell.org http://www.has

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 Antoine Latter
On Tue, Sep 28, 2010 at 9:05 AM, Felipe Lessa wrote: > On Tue, Sep 28, 2010 at 11:01 AM, Antoine Latter 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

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 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 Hoogle [2] nor

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 wrote: > On Tue, Sep 28, 2010 at 10:41 AM, Peter Robinson 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

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 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 (I <$> readTV

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 isolat

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

2010-09-28 Thread Peter Robinson
On 28 September 2010 15:35, Tom Hawkins 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 http://www.haskell.org/gh

[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 si