Module

Concurrent.Channel.Stream

Package
purescript-channel-stream
Repository
ConnorDillon/purescript-channel-stream

#streamChannel Source

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 Source

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

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

#streamOutput Source

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 Source

newtype Output a

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

Constructors

Instances

#Input Source

newtype Input a

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

Constructors

Instances

#Channel Source

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 Source

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 Source

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

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