Module

Concurrent.Channel.Stream

#streamChannel

streamChannel :: Duplex -> Effect (Channel Buffer Buffer)

Creates a new Channel with a provided duplex Stream as backend. Closing the Channel will destroy the Stream.

#streamInput

streamInput :: forall a. Readable a -> Effect (Input Buffer)

Creates a new Input with a provided readable Stream as backend.

#streamOutput

streamOutput :: forall a. Writable a -> Effect (Output Buffer)

Creates a new Output with a provided writable Stream as backend.

Re-exports from Concurrent.Channel

#Output

newtype Output a

An Output is a wrapper around a function that sends values to a Channel.

Constructors

Instances

#Input

newtype Input a

An Input is a wrapper around a function that receive values from a Channel.

Constructors

Instances

#Channel

type Channel o i = { close :: Aff Unit, input :: Input i, output :: Output o }

A Channel is an abstraction over a var, queue or stream backend and can be used as a communication channel between async threads.

#send

send :: forall a. Output a -> a -> Aff Boolean

Sends a value to an Output. Will return false if the Output is closed and true if not.

#recv

recv :: forall a. Input a -> Aff (Maybe a)

Receives a value from an Input. If the Input is closed, the result will be Nothing.

Modules