bug in dupChan

Simon Peyton-Jones simonpj at microsoft.com
Fri Jan 26 04:31:38 EST 2001


 
Shouldn't this instead be 
 
dupChan :: Chan a -> IO (Chan a)
dupChan (Chan _read write) = do
   new_read <- newEmptyMVar
   hole     <- readMVar write
   putMVar new_read hole
** putMVar write hole **
   return (Chan new_read write)

 No: readMVar is defined to be take-followed-by-put.  I think you
mis-read
the "readMVar write" as "takeMVar write".
 
Nevertheless, there is a bug in dupChan, but it's in the code for
readChan,
where "takeMVar read_end" should be "readMVar read_end".  As you'll
have seen if you are on the Haskell mailing list.  Shame on me!
 
Simon




More information about the Glasgow-haskell-bugs mailing list