Definition of emptiness for SampleVar

Simon Hengel simon.hengel at wiktory.org
Mon Nov 8 01:30:37 EST 2010


Hello,
I'm somewhat confused about the definition of emptiness for SampleVar: A
sample var is /empty/ if it contains no value _and_ if there are no
blocked readers[1].

With this definition, the following program prints `False':

    import Control.Concurrent

    main = do
      var <- newEmptySampleVar

      forkIO $ readSampleVar var

      threadDelay 1000000
      isEmptySampleVar var >>= print


Is this intended behavior? And if yes, what is the rational behind this?

If this is intended behavior, I'd tend to clarify the documentation?
Something like:

    Returns True if the SampleVar is currently empty and if there are no
    readers waiting.

Any thoughts on that?

Cheers,
Simon

[1] http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc/html/src/Control-Concurrent-SampleVar.html#isEmptySampleVar


More information about the Libraries mailing list