stm: newBroadcastTChan and friends (a proposal, and a question)
wren ng thornton
wren at freegeek.org
Mon May 13 07:24:57 CEST 2013
Hello all,
While looking through the pull requests for stm-chans I came across a
discrepancy in the new stm. Namely, we have the following definitions:
* stm == 2.4
newBroadcastTChan :: STM (TChan a)
newBroadcastTChan = do
dummy_hole <- newTVar TNil
write_hole <- newTVar TNil
read <- newTVar dummy_hole
write <- newTVar write_hole
return (TChan read write)
newBroadcastTChanIO :: IO (TChan a)
newBroadcastTChanIO = do
dummy_hole <- newTVarIO TNil
write_hole <- newTVarIO TNil
read <- newTVarIO dummy_hole
write <- newTVarIO write_hole
return (TChan read write)
* stm == 2.4.2
newBroadcastTChan :: STM (TChan a)
newBroadcastTChan = do
write_hole <- newTVar TNil
read <- newTVar (error ...)
write <- newTVar write_hole
return (TChan read write)
newBroadcastTChanIO :: IO (TChan a)
newBroadcastTChanIO = do
dummy_hole <- newTVarIO TNil
write_hole <- newTVarIO TNil
read <- newTVarIO dummy_hole
write <- newTVarIO write_hole
return (TChan read write)
Thus, whoever changed the definition of newBroadcastTChan in 2.4.2 forgot
to change newBroadcastTChanIO to keep it in sync.
PROPOSAL: I propose changing newBroadcastTChanIO to match
newBroadcastTChan. (Deadline: 2 weeks)
QUESTION: Is there any way to re-implement these functions using only the
public API of version 2.3?
--
Live well,
~wren
More information about the Libraries
mailing list