tryTakeMVar :: MVar a -> IO (Maybe a)

2000-04-08 Thread Marcin 'Qrczak' Kowalczyk

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.

-- 
 __("$ 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-





Re: [dongen@cs.ucc.ie: Re: Debugging techniques]

2000-04-08 Thread 'Marc van Dongen'

Simon Peyton Jones ([EMAIL PROTECTED]) wrote:

: | This is really a big problem. I have been strugling with it
: | myself. The safest thing to do is to use `error' (sad but
: | true). That's the only thing I can recommend:-(
: 
: This is a long-standing and embarassing bug which is
: alas not quick to fix.  But have now been embarassed fo
: often that we (aka Simon M) will fix it.

That's really great! Thank ye (aka Simon M) a lot!

Regards,


Marc