The module containing all the different types of channels in CHP. Unlike
JCSP and C++CSP2, CHP does not offer buffered channels directly (see the
Control.Concurrent.CHP.Buffers module). There are four different channel types, effectively
all possible combinations of:
- Shared reader vs non-shared reader
- Shared writer vs non-shared writer
For most applications you probably want just OneToOneChannel.
It is possible for the type system to infer which channel you want when
you use newChannel. If the types of the ends are known by the type system,
the channel-type can be inferred. So you can usually just write newChannel,
and depending on how you use the channel, the type system will figure out
which one you needed.
|A channel type, that can be used to get the ends of the channel via reader
|A class used for allocating new channels, and getting the reading and
writing ends. There is a bijective assocation between the channel, and
its pair of end types. You can see the types in the list of instances below.
Thus, newChannel may be used, and the compiler will infer which type of
channel is required based on what end-types you get from reader and writer.
Alternatively, if you explicitly type the return of newChannel, it will
be definite which ends you will use. If you do want to fix the type of
the channel you are using when you allocate it, consider using one of the
many oneToOneChannel-like shorthand functions that fix the type.
|Allocates a new channel. Nothing need be done to
destroy/de-allocate the channel when it is no longer in use.
A helper function that uses the parallel strategies library (see the
paper: "Algorithm + Strategy = Parallelism", P.W. Trinder et al, JFP
to make sure that the value sent down a channel is strictly evaluated
by the sender before transmission.
This is useful when you want to write worker processes that evaluate data
and send it back to some "harvester" process. By default the values sent
back may be unevaluated, and thus the harvester might end up doing the evaluation.
If you use this function, the value is guaranteed to be completely evaluated
Added in version 1.0.2.
|Like newChannel but also associates a label with that channel in a
trace. You can use this function whether tracing is turned on or not,
so if you ever use tracing, you should use this rather than newChannel.
|A helper that is like newChannel but returns the writing and reading
end of the channels directly.
|A helper that is like newChannel but returns the reading and writing
end of the channels directly.
|class ChannelTuple t where||Source|
A helper class for easily creating several channels of the same type.
The same type refers not only to what type the channel carries, but
also to the type of channel (one-to-one no poison, one-to-any with
poison, etc). You can write code like this:
(a, b, c, d, e) <- newChannels
To create five channels of the same type.
|Channel r w => ChannelTuple ((,) (Chan r w a) (Chan r w a))|
|Channel r w => ChannelTuple ((,,) (Chan r w a) (Chan r w a) (Chan r w a))|
|Channel r w => ChannelTuple ((,,,) (Chan r w a) (Chan r w a) (Chan r w a) (Chan r w a))|
|Channel r w => ChannelTuple ((,,,,) (Chan r w a) (Chan r w a) (Chan r w a) (Chan r w a) (Chan r w a))|
|Channel r w => ChannelTuple ((,,,,,) (Chan r w a) (Chan r w a) (Chan r w a) (Chan r w a) (Chan r w a) (Chan r w a))|
|Creates a list of channels of the same type with the given length. If
you need to access some channels by index, use this function. Otherwise
you may find using newChannels to be easier.
|A helper that is like newChannelList, but labels the channels with the
given list. The number of channels returned is the same as the length of
the list of labels
|A helper that is like newChannelList, but labels the channels according
to a pattern. Given a stem such as foo, it names the channels in the list
foo0, foo1, foo2, etc.
|Gets the channel's identifier. Useful if you need to be able to identify
a channel in the trace later on.
|A reading channel-end type that allows poison to be thrown
|A writing channel-end type that allows poison to be thrown
|Gets the reading end of a channel from its Chan type.
|Gets the writing end of a channel from its Chan type.
|Gets all the reading ends of a list of channels. A shorthand for map
|Gets all the writing ends of a list of channels. A shorthand for map
|Reading and Writing with Channels
|class ReadableChannel chanEnd where||Source|
|A class indicating that a channel can be read from.
|Reads from the given reading channel-end
|Performs an extended read from the channel, performing the given action
before freeing the writer
|class WriteableChannel chanEnd where||Source|
|A class indicating that a channel can be written to.
|writeChannel :: chanEnd a -> a -> CHP ()||Source|
|Writes from the given writing channel-end
|Starts the communication, then performs the given extended action, then
sends the result of that down the channel
|Claims the given channel-end, executes the given block, then releases
the channel-end and returns the output value. If poison or an IO
exception is thrown inside the block, the channel is released and the
|A wrapper (usually around a channel-end) indicating that the inner item
is shared. Use the claim function to use this type.
|Specific Channel Types
|All the functions here are equivalent to newChannel, but typed. So for
example, oneToOneChannel = newChannel :: MonadCHP m => m OneToOneChannel.
|Produced by Haddock version 2.3.0|