Data.AVar.Unsafe has a similar interface to Data.AVar, but instead of letting the user handle exceptions from Eithers, it will throw exceptions caught by the variable.
- data AVar a
- data Result = OK
- getAVar :: AVar a -> IO a
- putAVar :: AVar a -> a -> IO ()
- modAVar :: AVar a -> (a -> a) -> IO ()
- modAVar' :: AVar a -> (a -> (a, b)) -> IO b
- justModAVar :: AVar a -> (a -> a) -> IO ()
- condModAVar :: AVar a -> (a -> Bool) -> (a -> a) -> (a -> a) -> IO Bool
- swapAVar :: AVar a -> a -> IO a
- newAVar :: a -> IO (AVar a)
Documentation
AVar
s are the means through which communication with the variable are
conducted. They contain a Chan that is connected
to the variable, and
is read by the variable's handler
function.
putAVar :: AVar a -> a -> IO ()Source
putAVar
replaces the currect value in the variable with the given x
modAVar :: AVar a -> (a -> a) -> IO ()Source
modAVar
takes a function from a to a, and modifies the variable. It will
throw any exceptions caught by the variable when applying the function.
modAVar' :: AVar a -> (a -> (a, b)) -> IO bSource
modAVar'
is like modAVar, but it modifies the variable, along with
returning a result of type b. It also throws any errors caugh by the variable.
justModAVar :: AVar a -> (a -> a) -> IO ()Source
justModAVar
will attempt to run the given function on the variable.
It does not report back on its sucess or failure, and if the function
produces an exception, the variable is left unchanged. It should be
used when you just want to modify the variable, and keep running,
without waiting for the action to complete.
condModAVar :: AVar a -> (a -> Bool) -> (a -> a) -> (a -> a) -> IO BoolSource
condModAVar
applies the first finction to the current value in the
AVar, and will modify the value using the second function if
it results in True
, or the third function if it results in Fasle
.