Proposal: split Chan and TChan into read and write ends

Henning Thielemann lemming at henning-thielemann.de
Sat Oct 27 09:52:13 CEST 2012


On Fri, 26 Oct 2012, Brandon Simmons wrote:

> Hi everybody,
> Just discovered all the great discussion here, and although my
> google-fu turned up no prior discussions on this subject, I apologize
> if it has already been discussed.
>
> I propose that Chan and TChan should be implemented as a pair of read
> and write ends, initialized as follows:
>
>    newSplitChan :: IO (InChan a, OutChan a)
>
> I've implemented this already here:
> http://hackage.haskell.org/package/chan-split . You can ignore the
> type classes I've defined; they're there for my own reasons and not
> part of the proposal.


I have implemented something similar in plain Haskell 98:
    http://hackage.haskell.org/package/concurrent-split

  When using it I found that often there is a clear distinction between 
input and output end of a channel but sometimes it is not. E.g. a thread 
might send messages to itself. Of course I could pass around both channel 
ends in this case.
  I don't think it is worth to break the API. I am happy with separate 
packages. If the implementors of Control.Concurrent think that the 
implementations become cleaner then they might add new modules. This would 
allow for a smooth transition.



More information about the Libraries mailing list