Module

Run.Streaming.Prelude

Package
purescript-run-streaming
Repository
natefaubion/purescript-run-streaming

#forever Source

forever :: forall b a r. Run r a -> Run r b

Loop an effect forever.

#cat Source

cat :: forall a x r. Run (Transformer x x r) a

Forwards incoming values downstream.

#map Source

map :: forall a o i r. (i -> o) -> Run (Transformer i o r) a

Adapts incoming values.

#filter Source

filter :: forall a x r. (x -> Boolean) -> Run (Transformer x x r) a

Filters incoming values based on a predicate.

#each Source

each :: forall f x r. Foldable f => f x -> Run (Producer x r) Unit

Turns an arbitrary Foldable into a Producer.

#concat Source

concat :: forall a f x r. Foldable f => Run (Transformer (f x) x r) a

Forwards all individual values in an incoming Foldable downstream.

#concatMap Source

concatMap :: forall a f o i r. Foldable f => (i -> f o) -> Run (Transformer i o r) a

Composition of map followed by concat.

#take Source

take :: forall x r. Int -> Run (Transformer x x r) Unit

Takes a specified number of values from the head of the stream, terminating upon completion.

#takeWhile Source

takeWhile :: forall x r. (x -> Boolean) -> Run (Transformer x x r) Unit

Takes values from the head of the stream as determined by the provided predicate. Terminates when the predicate fails.

#drop Source

drop :: forall a x r. Int -> Run (Transformer x x r) a

Drops a specified number of values from the head of the stream.

#dropWhile Source

dropWhile :: forall a x r. (x -> Boolean) -> Run (Transformer x x r) a

Drops values from the head of the stream as determined by the provided predicate. Forwards all subsequent values.

#scan Source

scan :: forall a x o i r. (x -> i -> x) -> x -> (x -> o) -> Run (Transformer i o r) a

Folds over the input, yielding each step.

#zipWith Source

zipWith :: forall a k j i r. (i -> j -> k) -> Run (Producer i (Producer k r)) a -> Run (Producer j (Producer k r)) a -> Run (Producer k r) a

Joins two Producers into one.

#zip Source

zip :: forall a j i r. Run (Producer i (Producer (Tuple i j) r)) a -> Run (Producer j (Producer (Tuple i j) r)) a -> Run (Producer (Tuple i j) r) a

Joins two Producers with a Tuple.

#succ Source

succ :: forall x r. Enum x => x -> Run (Producer x r) Unit

Yields successive values until exhausted.

#null Source

null :: forall x r. Run (Producer x r) Unit -> Run r Boolean

Checks whether a Producer is empty.

#head Source

head :: forall x r. Run (Producer x r) Unit -> Run r (Maybe x)

Returns the first value of a Producer.

#last Source

last :: forall x r. Run (Producer x r) Unit -> Run r (Maybe x)

Returns the last value of a Producer.

#all Source

all :: forall x r. (x -> Boolean) -> Run (Producer x (Producer x r)) Unit -> Run r Boolean

Checks if all yielded values from a Producer satisfy the predicate. Stops as soon as one fails.

#any Source

any :: forall x r. (x -> Boolean) -> Run (Producer x (Producer x r)) Unit -> Run r Boolean

Checks if any yielded values from a Producer satisfy the predicate. Stops as soon as one passes.

#and Source

and :: forall r. Run (Producer Boolean (Producer Boolean r)) Unit -> Run r Boolean

Checks if all yielded values are true.

#or Source

or :: forall r. Run (Producer Boolean (Producer Boolean r)) Unit -> Run r Boolean

Checks if any yielded values are true.

#elem Source

elem :: forall x r. Eq x => x -> Run (Producer x (Producer x r)) Unit -> Run r Boolean

Checks if a value occurs in the stream.

#find Source

find :: forall x r. (x -> Boolean) -> Run (Producer x (Producer x r)) Unit -> Run r (Maybe x)

Finds the first value that satisfies the provided predicate.

#index Source

index :: forall x r. Int -> Run (Producer x (Producer x r)) Unit -> Run r (Maybe x)

Finds the value at the given offset in the stream.

#findIndex Source

findIndex :: forall x r. (x -> Boolean) -> Run (Producer x (Producer (Tuple Int x) (Producer (Tuple Int x) r))) Unit -> Run r (Maybe (Tuple Int x))

Finds the index for the first value that satisfies the provided predicate.

#fold Source

fold :: forall x o i r. (x -> i -> x) -> x -> (x -> o) -> Run (Producer i r) Unit -> Run r o

Folds over a Producer, returning the summary.

#fold' Source

fold' :: forall a x o i r. (x -> i -> x) -> x -> (x -> o) -> Run (Producer i r) a -> Run r (Tuple o a)

Folds over a Producer, but also returns the final value of the stream.

#foldM Source

foldM :: forall x o i r. (x -> i -> Run r x) -> Run r x -> (x -> Run r o) -> Run (Producer i r) Unit -> Run r o

Folds over a Producer with Run effects.

#foldM' Source

foldM' :: forall a x o i r. (x -> i -> Run r x) -> Run r x -> (x -> Run r o) -> Run (Producer i r) a -> Run r (Tuple o a)

Folds over a Producer with Run effects, but also returns the final value of the stream.

#length Source

length :: forall x r. Run (Producer x r) Unit -> Run r Int

Returns the number of values yielded by a Producer.

#sum Source

sum :: forall x r. Semiring x => Run (Producer x r) Unit -> Run r x

Returns the sum of values yielded by a Producer.

#product Source

product :: forall x r. Semiring x => Run (Producer x r) Unit -> Run r x

Returns the product of values yielded by a Producer.

#minimum Source

minimum :: forall x r. Ord x => Run (Producer x r) Unit -> Run r (Maybe x)

Returns the minimum value yielded by a Producer.

#maximum Source

maximum :: forall x r. Ord x => Run (Producer x r) Unit -> Run r (Maybe x)

Returns the maximum value yielded by a Producer.

#unfold Source

unfold :: forall a o x r. (x -> Either a (Tuple o x)) -> x -> Run (Producer o r) a

Unfold into a Producer given a seed.

Re-exports from Run.Streaming

#Transformer Source

type Transformer i o r = (await :: AWAIT i, yield :: YIELD o | r)

Transformers await values i and yield values o using effects r.

#Server Source

type Server req res r = (yield :: RESPOND req res | r)

Servers reply to requests req with responses res using effects r.

#Producer Source

type Producer o r = (yield :: YIELD o | r)

Producers yield values of type o using effects r.

#Pipe Source

type Pipe req res req' res' r = (await :: REQUEST req res, yield :: RESPOND req' res' | r)

A full bidirectional Pipe acts as an upstream Client and a downstream Server.

#Consumer Source

type Consumer i r = (await :: AWAIT i | r)

Consumers await values of type i using effects r.

#Client Source

type Client req res r = (await :: REQUEST req res | r)

Clients issue requests req and await responses res using effects r.

#yield Source

yield :: forall r o. o -> Run (Producer o r) Unit

Yields a value to be consumed downstream.

#respond Source

respond :: forall r res req. res -> Run (Server req res r) req

Yields a response and waits for a request.

#request Source

request :: forall r res req. req -> Run (Client req res r) res

Issues a request and awaits a response.

#await Source

await :: forall r i. Run (Consumer i r) i

Awaits a value upstream.

Re-exports from Run.Streaming.Pull

#into Source

into :: forall a x r. Run (Consumer x r) a -> Run r x -> Run r a

Connects a Consumer to an effect which fulfills the request.

#feed Source

feed :: forall a x r. Run (Consumer x r) a -> Run (Producer x r) a -> Run r a

Connects a Consumer to a Producer.

#consume Source

consume :: forall b a x r. (x -> Run (Consumer x r) a) -> Run (Consumer x r) b

Consumes all values with effects.

Re-exports from Run.Streaming.Push

#traverse Source

traverse :: forall a o i r. (o -> Run r i) -> Run (Server i o r) a -> Run r a

Loops over a Server/Producer with effects, feeding the result in as a request.

#produce Source

produce :: forall a x r. Run (Producer x r) x -> Run (Producer x r) a

Produce values via an effect.

#for Source

for :: forall a o i r. Run (Server i o r) a -> (o -> Run r i) -> Run r a

traverse with the arguments flipped.