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
AVars 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
putAVar replaces the currect value in the variable with the given x
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' 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 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.