Wouldn't be nice to have such function?

I wanted to translate a thread example written in Ruby and realized
that it's impossible to write that function using MVar primitives
provided; and no module seems to provide an equivalent using
another kind of concurrent variable. I had to simulate mutexes with
MVar (Maybe [MVar ()]) instead of MVar (). I guess that this function
should be possible to implement on plain MVars.

The semantics is obvious: if the variable is empty, return Nothing,
else take its value and return Just it.

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/              GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
  ^^                  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK                  5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-


Reply via email to