I find the documentation of takeMVar and readMVar in section 1.4.1 confusing
if not non-existent.  The only documentation appears to be (apart from the
types themselves):

   MVars are rendezvous points, mostly for concurrent threads. They begin
   either empty or full, and any attempt to read an empty MVar blocks.
   When an MVar is written, a single blocked thread may be freed. Reading
   an MVar toggles its state from full back to empty. Therefore, any
   value written to an MVar may only be read once. Multiple reads and
   writes are allowed, but there must be at least one read between any 
   two writes. 

Now it turns out that "takeMVar" corresponds to "read" in this paragraph,
and "readMVar" corresponds to a read which DOESN'T empty the value (or in GHC's
implementation, empties it and then immediately puts it back).

Reply via email to