[Haskell-cafe] Stronger STM primitives needed? Or am I just doing it wrong?

Ryan Ingram ryani.spam at gmail.com
Wed Apr 23 15:12:15 EDT 2008

On 4/23/08, Jan-Willem Maessen <jmaessen at alum.mit.edu> wrote:
> I've been trying to decide whether either of these is implementable in terms
> of `orElse`, in such a way that we immediately check the predicate upon
> retry before doing anything else.   I can't quite make up my mind whether
> this is possible or not.

I do not think it is possible; consider this case:

broken = atomically $ do
   v <- expensive_computation :: STM (TVar Int)
   retryUntil v (> 50)

Given that you don't know which tvar to use until the end of the
expensive computation, I don't see how you can lift "orElse" to the
make that tvar be the first thing checked when the transaction is

More information about the Haskell-Cafe mailing list