Control.Concurrent.Chan: how do i close a channel?

Donald Bruce Stewart dons at cse.unsw.edu.au
Mon Jul 16 08:18:20 EDT 2007


claus.reinke:
> in principle, Chan looks like a nice way to do pipes within
> haskell code, or to avoid unsafeInterleaveIO, in combination
> with getChanContents (which explicitly mentions hGetContents
> in its API doc).
> 
> however, i seem to be missing a way to close a channel?
> am i misinterpreting this library?

They're not attached to Handles -- that's the IO loop that does the
writing to the Chan's job -- so they dont' really have a 'close'. When
you're done writing, just stop writing.

I often use Chan (Maybe a), with Nothing to tell the reader thread that
EOF is reached -- perhaps something like that is what you're looking
for?

-- Don


More information about the Libraries mailing list