bug in dupChan

Simon Peyton-Jones simonpj@microsoft.com
Fri, 26 Jan 2001 01:31:38 -0800


=20
Shouldn't this instead be=20
=20
dupChan :: Chan a -> IO (Chan a)
dupChan (Chan _read write) =3D 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".
=20
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!
=20
Simon