Hi,<br><br>I&#39;m getting strange behavior when using the &#39;many&#39; combinator to read zero or more items off of a TQueue with readTQueue. The script that exhibits this behavior is as follows:<font face="courier new,monospace"><br>
</font><pre>import Control.Concurrent.STM
import Control.Concurrent
import Control.Monad
import Control.Applicative
<br>main = do
    q &lt;- newTQueueIO
    atomically $ writeTQueue q True
    atomically $ writeTQueue q False
    forever $ do
        xs &lt;- atomically $ many $ readTQueue q
        print xs
        threadDelay 500000
</pre><br>I&#39;d expect the output of the script to be:<br><span style="font-family:courier new,monospace">[True,False]<br>[]<br>[]<br>...</span><br><br>However, that is not the case: the actual output of the script is:<br>
<span style="font-family:courier new,monospace">[True,False]<br>[True,False]<br>[True,False]<br>...</span><br><br>This means that TQueue is incompatible with TChan, since if TQueue is replaced by TChan then the script behaves as one would expect.<br>
<br>If 1 element (say, True) is written into the TQueue instead of 2, then the output of the script is:<br><span style="font-family:courier new,monospace">[True]<br>[]<br>[]<br></span>...<br><br>Which is expected behavior, but inconsistent with the behavior when the TQueue has 2 or more elements in it.<br>
<br>Is this considered a bug, or undocumented behavior of TQueue?<br>