Safe Haskell | None |
---|---|

Language | Haskell98 |

If you don't know exactly what this module is for and precisely how to use the types within, you should move on, quickly!

- data PCopy a
- pCopy :: Typeable a => a -> PCopy a
- matchP :: Typeable m => Match (Maybe m)
- matchChanP :: Typeable m => ReceivePort (PCopy m) -> Match m
- pUnwrap :: Typeable m => Message -> Process (Maybe m)
- data InputStream a = Null
- newInputStream :: forall a. Typeable a => Either (ReceivePort a) (STM a) -> InputStream a
- matchInputStream :: InputStream a -> Match a
- readInputStream :: Serializable a => InputStream a -> Process a
- data InvalidBinaryShim = InvalidBinaryShim

# Copying non-serializable data

pCopy :: Typeable a => a -> PCopy a Source

Wrap any `Typeable`

datum in a `PCopy`

. We hide the constructor to
discourage arbitrary uses of the type, since `PCopy`

is a specialised
and potentially dangerous construct.

matchP :: Typeable m => Match (Maybe m) Source

Matches on `PCopy m`

and returns the *m* within.
This potentially allows us to bypass serialization (and the type constraints
it enforces) for local message passing (i.e., with `UnencodedMessage`

data),
since PCopy is just a shim.

matchChanP :: Typeable m => ReceivePort (PCopy m) -> Match m Source

Matches on a `TypedChannel (PCopy a)`

.

pUnwrap :: Typeable m => Message -> Process (Maybe m) Source

Given a raw `Message`

, attempt to unwrap a `Typeable`

datum from
an enclosing `PCopy`

wrapper.

# Arbitrary (unmanaged) message streams

data InputStream a Source

A generic input channel that can be read from in the same fashion
as a typed channel (i.e., `ReceivePort`

). To read from an input stream
in isolation, see `readInputStream`

. To compose an `InputStream`

with
reads on a process' mailbox (and/or typed channels), see `matchInputStream`

.

newInputStream :: forall a. Typeable a => Either (ReceivePort a) (STM a) -> InputStream a Source

Create a new `InputStream`

.

matchInputStream :: InputStream a -> Match a Source

Constructs a `Match`

for a given `InputChannel`

.

readInputStream :: Serializable a => InputStream a -> Process a Source

Read from an `InputStream`

. This is a blocking operation.