[Haskell-cafe] New STM Data Structures Collection
Richard A. O'Keefe
ok at cs.otago.ac.nz
Fri Oct 23 00:27:06 UTC 2015
I'm really puzzled by the interface.
class Bag b
where
new :: STM (b v)
-- no problem here
add :: b v -> v -> STM ()
-- no problem here
isEmpty :: b v -> STM Bool
-- no real problem except the pervasive one that whatever
-- you learn about the state of a concurrent object must
-- always be treated as out of date when you use it
take :: b v -> STM v
-- what is supposed to happen if the bag is empty?
I was expecting an operation like
maybeTake :: b v -> STM (Maybe v)
More information about the Haskell-Cafe
mailing list