[Haskell-cafe] Lock-Free Data Structures using STMs in Haskell

Ariel J. Birnbaum valgarv at gmx.net
Wed Apr 9 15:23:59 EDT 2008


> >   decPair v1 v1 :: TVar Int -> TVar Int -> IO ()
> >   decPair v1 v2 = atomically (decT v1 `orElse` decT v2)
> >
> > Will this actually compile?  I was under the impression that 'orElse'
> > could only combine STM types, not IO () types.
>
> The type of atomically is STM a -> IO a.

But orElse :: STM a -> STM a -> STM a

decT can be of type TVar Int -> STM () if you leave out the atomically.

-- 
Ariel J. Birnbaum


More information about the Haskell-Cafe mailing list