hspread-0.3: A client library for the spread toolkitContentsIndex
Control.Concurrent.Chan.Closeable
Portabilitynon-portable (concurrency)
Stabilityexperimental
Maintainersanzhiyan@gmail.com
Contents
The Chan type
Operations
Stream interface
Description
Unbounded closeable channels.
Synopsis
data Chan t a
data R
data W
newChan :: IO (Chan R a, Chan W a)
writeChan :: Chan W a -> a -> IO Bool
closeChan :: Chan W a -> IO Bool
isClosedChan :: Chan t a -> IO Bool
readChan :: Chan R a -> IO (Maybe a)
forkChan :: Chan t a -> IO (Chan R a)
unGetChan :: Chan R a -> a -> IO ()
isEmptyChan :: Chan R a -> IO Bool
getChanContents :: Chan R a -> IO [a]
writeList2Chan :: Chan W a -> [a] -> IO (Maybe [a])
The Chan type
data Chan t a
Chan is an abstract type representing an unbounded FIFO channel.
data R
R for ReadOnly
data W
W for WriteOnly
Operations
newChan :: IO (Chan R a, Chan W a)
Build and returns a pair of Chan, data written on the W end can be read from the R end.
writeChan :: Chan W a -> a -> IO Bool
Write a value to a Chan. Returns True if successful, False if the channel is closed.
closeChan :: Chan W a -> IO Bool
Close the Chan, data can be no more written to it. Returns True if the Chan was already closed.
isClosedChan :: Chan t a -> IO Bool
Non-blocking check.
readChan :: Chan R a -> IO (Maybe a)
Read the next value from the Chan. |Nothing if the Chan is closed.
forkChan :: Chan t a -> IO (Chan R a)
Forks a Chan: data that will be written (W) or is yet to be read (R) on the argument, will also be available on the returned channel.
unGetChan :: Chan R a -> a -> IO ()
Put a data item back onto a channel, where it will be the next item read.
isEmptyChan :: Chan R a -> IO Bool
Returns True if the supplied Chan is empty, i.e. readChan won't block.
Stream interface
getChanContents :: Chan R a -> IO [a]
Return a lazy list representing the contents of the supplied Chan, much like hGetContents.
writeList2Chan :: Chan W a -> [a] -> IO (Maybe [a])
Write an entire list of items to a Chan. Returning the remainder if the channel has been closed meanwhile.
Produced by Haddock version 0.8