Module

FRP.Behavior

Package
purescript-behaviors
Repository
paf31/purescript-behaviors

#Behavior Source

newtype Behavior a

A Behavior acts like a continuous function of time.

We can construct a sample a Behavior from some Event, combine Behaviors using Applicative, and sample a final Behavior on some other Event.

Instances

#behavior Source

behavior :: forall a. (forall b. Event (a -> b) -> Event b) -> Behavior a

Construct a Behavior from its sampling function.

#step Source

step :: forall a. a -> Event a -> Behavior a

Create a Behavior which is updated when an Event fires, by providing an initial value.

#unfold Source

unfold :: forall b a. (a -> b -> b) -> Event a -> b -> Behavior b

Create a Behavior which is updated when an Event fires, by providing an initial value and a function to combine the current value with a new event to create a new value.

#sample Source

sample :: forall b a. Behavior a -> Event (a -> b) -> Event b

Sample a Behavior on some Event.

#sampleBy Source

sampleBy :: forall c b a. (a -> b -> c) -> Behavior a -> Event b -> Event c

Sample a Behavior on some Event by providing a combining function.

#sample_ Source

sample_ :: forall b a. Behavior a -> Event b -> Event a

Sample a Behavior on some Event, discarding the event's values.

#integral Source

integral :: forall t a. Field t => Semiring a => (t -> a -> a) -> Behavior t -> Behavior a -> Behavior a

Integrate with respect to some measure of time.

This function approximates the integral using the trapezium rule at the implicit sampling interval.

#derivative Source

derivative :: forall t a. Field t => Ring a => (a -> t -> a) -> Behavior t -> Behavior a -> Behavior a

Differentiate with respect to some measure of time.

This function approximates the derivative using a quotient of differences at the implicit sampling interval.