Module

Run.Streaming.Prelude

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

#forever Source

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

Loop an effect forever.

#cat Source

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

Forwards incoming values downstream.

#map Source

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

Adapts incoming values.

#filter Source

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

Filters incoming values based on a predicate.

#each Source

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

Turns an arbitrary Foldable into a Producer.

#concat Source

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

Forwards all individual values in an incoming Foldable downstream.

#concatMap Source

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

Composition of map followed by concat.

#take Source

take :: forall r x. 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 r x. (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 r x a. Int -> Run (Transformer x x r) a

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

#dropWhile Source

dropWhile :: forall r x a. (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 r i o x a. (x -> i -> x) -> x -> (x -> o) -> Run (Transformer i o r) a

Folds over the input, yielding each step.

#zipWith Source

zipWith :: forall r i j k a. (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 r i j a. 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 r x. Enum x => x -> Run (Producer x r) Unit

Yields successive values until exhausted.

#null Source

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

Checks whether a Producer is empty.

#head Source

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

Returns the first value of a Producer.

#last Source

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

Returns the last value of a Producer.

#all Source

all :: forall r x. (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 r x. (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 r x. 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 r x. (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 r x. 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 r x. (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 r i o x. (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 r i o x a. (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 r i o x. (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 r i o x a. (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 r x. Run (Producer x r) Unit -> Run r Int

Returns the number of values yielded by a Producer.

#sum Source

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

Returns the sum of values yielded by a Producer.

#product Source

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

Returns the product of values yielded by a Producer.

#minimum Source

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

Returns the minimum value yielded by a Producer.

#maximum Source

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

Returns the maximum value yielded by a Producer.

#unfold Source

unfold :: forall r x o a. (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 o r. o -> Run (Producer o r) Unit

Yields a value to be consumed downstream.

#respond Source

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

Yields a response and waits for a request.

#request Source

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

Issues a request and awaits a response.

#await Source

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

Awaits a value upstream.

Re-exports from Run.Streaming.Pull

#into Source

into :: forall r x a. 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 r x a. Run (Consumer x r) a -> Run (Producer x r) a -> Run r a

Connects a Consumer to a Producer.

#consume Source

consume :: forall r x a b. (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 r i o a. (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 r x a. Run (Producer x r) x -> Run (Producer x r) a

Produce values via an effect.

#for Source

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

traverse with the arguments flipped.