Module

SodiumFRP.Stream

Package
purescript-sodium
Repository
SodiumFRP/purescript-sodium

#mapTo Source

mapTo :: forall str b a. SodiumStream str => b -> str a -> Stream b

Transform the stream's event values into the specified constant value. b is a constant value.

#orElse Source

orElse :: forall str a. SodiumStream str => str a -> str a -> Stream a

Variant of 'merge' that merges two streams and will drop an event in the simultaneous case of two events in the same Transaction

The events from the first stream take priority here In other words it's eqivilent to merge (\l r -> l) s1 s2

If you want to specify your own merging function, use 'merge'

#merge Source

merge :: forall str a. SodiumStream str => (a -> a -> a) -> str a -> str a -> Stream a

Merges two streams and will drop an event in the simultaneous case of two events in the same Transaction

The supplied function determines which event to drop

It may construct FRP logic or use sample() Apart from this the function must be referentially transparent.

#filter Source

filter :: forall str a. SodiumStream str => (a -> Boolean) -> str a -> Stream a

Return a stream that only outputs events for which the predicate returns true.

#gate Source

gate :: forall cel str a. SodiumStream str => SodiumCell cel => str a -> cel Boolean -> Stream a

Return a stream that only outputs events from the input stream when the specified cell's value is true.

#snapshot1 Source

snapshot1 :: forall cel str a. SodiumStream str => SodiumCell cel => str a -> cel a -> Stream a

Variant of 'snapshot' that captures the cell's value at the time of the event firing, ignoring the stream's value.

#snapshot Source

snapshot :: forall str cel c b a. SodiumStream str => SodiumCell cel => (a -> b -> c) -> str a -> cel b -> Stream c

Return a stream whose events are the result of the combination using the specified function of the input stream's event value and the value of the cell at that time.

There is an implicit delay: State updates caused by event firings being held with 'hold' don't become visible as the cell's current value until the following transaction. To put this another way, 'snapshot' always sees the value of a cell as it was before any state changes from the current transaction.

#snapshot3 Source

snapshot3 :: forall str cel d c b a. SodiumStream str => SodiumCell cel => (a -> b -> c -> d) -> str a -> cel b -> cel c -> Stream d

#snapshot4 Source

snapshot4 :: forall str cel e d c b a. SodiumStream str => SodiumCell cel => (a -> b -> c -> d -> e) -> str a -> cel b -> cel c -> cel d -> Stream e

#snapshot5 Source

snapshot5 :: forall str cel f e d c b a. SodiumStream str => SodiumCell cel => (a -> b -> c -> d -> e -> f) -> str a -> cel b -> cel c -> cel d -> cel e -> Stream f

#snapshot6 Source

snapshot6 :: forall str cel g f e d c b a. SodiumStream str => SodiumCell cel => (a -> b -> c -> d -> e -> f -> g) -> str a -> cel b -> cel c -> cel d -> cel e -> cel f -> Stream g

#hold Source

hold :: forall str a. SodiumStream str => str a -> a -> Effect (Cell a)

Create a "Cell" with the specified initial value, that is updated by this stream's event values. There is an implicit delay: State updates caused by event firings don't become visible as the cell's current value as viewed by 'snapshot' until the following transaction. To put this another way, 'snapshot' always sees the value of a cell as it was before any state changes from the current transaction.

#collect Source

collect :: forall str c b a. SodiumStream str => (a -> c -> { state :: c, value :: b }) -> c -> str a -> Stream b

Transform an event with a generalized state loop (a Mealy machine). The function is passed the input and the old state and returns the new state and output value. The function may construct FRP logic or use 'sample' in which case it is equivalent to 'snapshot'ing the cell. Apart from this the function must be referentially transparent.

#accum Source

accum :: forall str b a. SodiumStream str => (a -> b -> b) -> b -> str a -> Cell b

Accumulate on input event, outputting the new state each time. The function may construct FRP logic or use 'sample' in which case it is equivalent to 'snapshot'ing the cell. Apart from this the function must be referentially transparent.

#once Source

once :: forall str a. SodiumStream str => str a -> Stream a

Return a stream that outputs only one value: the next event of the input stream, starting from the transaction in which once() was invoked.

#loopStream Source

loopStream :: forall str a. SodiumStream str => StreamLoop a -> str a -> Effect Unit

Resolve the loop to specify what the StreamLoop was a forward reference to. It must be invoked inside the same transaction as the place where the StreamLoop is used. This requires you to create an explicit transaction

#execute Source

execute :: forall str a. SodiumStream str => str (Effect a) -> Stream a

Runs the side effects as a map over stream events This is a safe thing to do in Sodium