MVar package:rebase

An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.
The thread is blocked on an MVar, but there are no other references to the MVar so it can't ever continue.
blocked on MVar
A TMVar is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.
Check whether a given MVar is empty. Notice that the boolean value returned is just a snapshot of the state of the MVar. By the time you get to react on its result, the MVar may have been filled (or emptied) - so be extremely careful when using this operation. Use tryTakeMVar instead if possible.
Check whether a given TMVar is empty.
Make a Weak pointer to an MVar, using the second argument as a finalizer to run when MVar is garbage-collected
Make a Weak pointer to a TMVar, using the second argument as a finalizer to run when the TMVar is garbage-collected.
A slight variation on modifyMVar_ that allows a value to be returned (b) in addition to the modified value of the MVar.
Like modifyMVar, but the IO action in the second argument is executed with asynchronous exceptions masked.
Like modifyMVar_, but the IO action in the second argument is executed with asynchronous exceptions masked.
An exception-safe wrapper for modifying the contents of an MVar. Like withMVar, modifyMVar will replace the original contents of the MVar if an exception is raised during the operation. This function is only atomic if there are no other producers for this MVar. In other words, it cannot guarantee that, by the time modifyMVar_ gets the chance to write to the MVar, the value of the MVar has not been altered by a write operation from another thread.
Create an MVar which is initially empty.
Create a TMVar which is initially empty.
IO version of newEmptyTMVar. This is useful for creating top-level TMVars using unsafePerformIO, because using atomically inside unsafePerformIO isn't possible.
Create an MVar which contains the supplied value.
Make a StablePtr that can be passed to the C function hs_try_putmvar(). The RTS wants a StablePtr to the underlying MVar#, but a StablePtr# can only refer to lifted types, so we have to cheat by coercing.
Create a TMVar which contains the supplied value.