I recently upgraded to ghc 7.0.2 from 6.12.3, along with the Haskell platform, and noticed that the following code no longer works as expected:<br><br><span style="font-family: courier new,monospace;">waitFor tvar = atomically $ do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    count &lt;- readTVar tvar</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    check (count == 0)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">worker tchan tvar = loop</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   where loop = do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">           putStrLn &quot;checking&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">           finished &lt;- atomically $ isEmptyTChan tchan</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">           threadDelay 50000</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">           if finished</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">              then atomically $ do val &lt;- readTVar tvar</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                                   writeTVar tvar $ (subtract 1) val</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">              else (atomically $ readTChan tchan) &gt;&gt; loop</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">test = do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  tchan &lt;- newTChanIO</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  pure $ forM_ [1..5] $ writeTChan tchan</span> -- THIS LINE <br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  tvar &lt;- newTVarIO 1</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  forkIO $ worker tchan tvar</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  waitFor tvar</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  putStrLn &quot;DONE&quot;</span><br><br>This will work if I use atomically, but otherwise it does nothing, tchan remains empty afterwards. <br>
I&#39;m not clear how this should behave.<br><br>