
22 Oct
2015
22 Oct
'15
11:33 p.m.
The isEmpty is not out of date as STM will detect if it is and restart the transaction. The take operation will block if the bag is empty. If this isn't clear in the documentation we should make it clearer. You can write a maybeTake using orElse:
maybeTake b = (Just <$> take b) `orElse` return Nothing
Note that this can also be written as maybeTake = optional . take where optional comes from Control.Applicative. -- Chris Wong (https://lambda.xyz) "I fear that Haskell is doomed to succeed." -- Tony Hoare