Module

SodiumFRP.Stream

#mapTo

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

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

#orElse

orElse :: forall a str. 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

merge :: forall a str. 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

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

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

#gate

gate :: forall a str cel. 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

snapshot1 :: forall a str cel. 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

snapshot :: forall a b c cel str. 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

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

#snapshot4

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

#snapshot5

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

#snapshot6

snapshot6 :: forall a b c d e f g cel str. 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

hold :: forall a str. 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

collect :: forall a b c str. 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

accum :: forall a b str. 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

once :: forall a str. 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

loopStream :: forall a str. 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

execute :: forall a str. 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

Modules