[Haskell-cafe] Other transactional arrays?
Felipe Lessa
felipe.lessa at gmail.com
Fri Jul 9 07:13:09 EDT 2010
On Fri, Jul 9, 2010 at 7:16 AM, Emil Melnicov <emilmeln at gmail.com> wrote:
>> writeTVector :: TVector a -> Int -> a -> STM ()
>> writeTVector (TVector t#) (I# i#) x = stm $ \s1# ->
>> case readTVar# t# s1# of { (# s2#, (MutableArray a#) #) ->
>> case writeArray# a# i# x s2# of { s3# ->
>> case writeTVar# t# (MutableArray a#) s3# of { s4# ->
>> (# s4#, () #) }}}
>
> It seems like it works, but I'm in doubt about it's correctness.
> Unfortunately, I don't know much about STM mechanics, so I'm asking
> Cafe users (you :-) for help.
I guess the only problem lies with writeTVector. I don't know much
about STM implementation details as well, but reading the code for
writeTVector I can't see how it could be rollbacked. I.e., should
something with writeTVector fail and rollback, how will the old value
get into the mutable array?
Cheers :)
--
Felipe.
More information about the Haskell-Cafe
mailing list