| elegant.  If MVar's were instances of Ord as well as Eq, a 
| neat solution would
| be to always get the least MVar first, but they aren't.  So 
| what should one do?

But you could make Flag an instance of Ord

        data Flag = MkFlag Int (MVar Bool)

Now newMVar needs to consult a global variable to get the
next Flag number, but after that there's no global locking.

This is, of course, precisely what we'd have to do to make
MVars an instance of Ord --- but it would impose a cost on
all MVars, whether or not they needed it, which is why we've not
done it.

Simon

Reply via email to