Copyright | (c) The University of Glasgow 2001 Don Stewart 2007 |
---|---|
License | BSD-style |
Maintainer | dons@galois.com |
Stability | experimental |
Portability | non-portable (concurrency) |
Safe Haskell | None |
Language | Haskell2010 |
Unbounded, element-strict channels. Elements will be evaluated to WHNF on entering the channel. For some concurrency applications, this is more desirable than passing an unevaluted thunk through the channel (for instance, it guarantees the node willl be evaluated to WHNF in a worker thead).
Element-strict channes may potentially use more memory than lazy channels
- data Chan a
- newChan :: NFData a => IO (Chan a)
- writeChan :: NFData a => Chan a -> a -> IO ()
- readChan :: NFData a => Chan a -> IO a
- dupChan :: NFData a => Chan a -> IO (Chan a)
- unGetChan :: NFData a => Chan a -> a -> IO ()
- isEmptyChan :: NFData a => Chan a -> IO Bool
- getChanContents :: NFData a => Chan a -> IO [a]
- writeList2Chan :: NFData a => Chan a -> [a] -> IO ()
The Chan
type
Operations
dupChan :: NFData a => Chan a -> IO (Chan a) Source #
Duplicate a Chan
: the duplicate channel begins empty, but data written to
either channel from then on will be available from both. Hence this creates
a kind of broadcast channel, where data written by anyone is seen by
everyone else.
unGetChan :: NFData a => Chan a -> a -> IO () Source #
Put a data item back onto a channel, where it will be the next item read.
Stream interface
getChanContents :: NFData a => Chan a -> IO [a] Source #
Return a lazy list representing the contents of the supplied
Chan
, much like hGetContents
.