-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Generic Mutable Ref Abstraction Layer
--
-- Ref is a generic layer over mutable references, currently only IO and
-- ST refs. Future extensions may include a generic api for shared state
-- concurrency.
@package ref
@version 0.1.1.2
module Data.Ref.CAS
-- | Performs a machine-level compare and swap operation on an
-- STRef. Returns a tuple containing a Bool which is
-- True when a swap is performed, along with the current
-- value from the STRef.
--
-- Note "compare" here means pointer equality in the sense of
-- reallyUnsafePtrEquality#.
casSTRef :: STRef s a -> a -> a -> ST s (Bool, a)
-- | Performs a machine-level compare and swap operation on an
-- IORef. Returns a tuple containing a Bool which is
-- True when a swap is performed, along with the current
-- value from the IORef.
--
-- Note "compare" here means pointer equality in the sense of
-- reallyUnsafePtrEquality#.
casIORef :: IORef a -> a -> a -> IO (Bool, a)
module Data.Ref
class Ref ref where type family RefM ref :: * -> *
newRef :: Ref ref => a -> RefM ref (ref a)
newRef' :: Ref ref => a -> RefM ref (ref a)
readRef :: Ref ref => ref a -> RefM ref a
readRef' :: Ref ref => ref a -> RefM ref a
writeRef :: Ref ref => ref a -> a -> RefM ref ()
writeRef' :: Ref ref => ref a -> a -> RefM ref ()
modifyRef :: Ref ref => ref a -> (a -> a) -> RefM ref ()
modifyRef' :: Ref ref => ref a -> (a -> a) -> RefM ref ()
instance Ref (STRef s)
instance Ref IORef