FRP.Behavior
- Package
- purescript-hyrule
- Repository
- mikesol/purescript-hyrule
#ABehavior Source
newtype ABehavior :: (Type -> Type) -> Type -> Typenewtype ABehavior event a
ABehavior is the more general type of Behavior, which is parameterized
over some underlying event type.
Normally, you should use Behavior instead, but this type
can also be used with other types of events, including the ones in the
Semantic module.
Instances
(Functor event) => Functor (ABehavior event)(Functor event) => Apply (ABehavior event)(Functor event) => Applicative (ABehavior event)(Functor event, Semigroup a) => Semigroup (ABehavior event a)(Functor event, Monoid a) => Monoid (ABehavior event a)(Functor event, HeytingAlgebra a) => HeytingAlgebra (ABehavior event a)(Functor event, Semiring a) => Semiring (ABehavior event a)(Functor event, Ring a) => Ring (ABehavior event a)
#gate Source
gate :: forall event a. Filterable event => ABehavior event Boolean -> event a -> event aFilter an Event by the boolean value of a Behavior.
#gateBy Source
gateBy :: forall event p a. Filterable event => (p -> a -> Boolean) -> ABehavior event p -> event a -> event aSample a Behavior on some Event by providing a predicate function.
#integral Source
integral :: forall event a t. IsEvent event => Field t => Semiring a => (((a -> t) -> t) -> a) -> a -> ABehavior event t -> ABehavior event a -> ABehavior event aIntegrate with respect to some measure of time.
This function approximates the integral using the trapezium rule at the implicit sampling interval.
The Semiring a should be a vector field over the field t. To represent
this, the user should provide a grate which lifts a multiplication
function on t to a function on a. Simple examples where t ~ a can use
the integral' function instead.
#integral' Source
integral' :: forall event t. IsEvent event => Field t => t -> ABehavior event t -> ABehavior event t -> ABehavior event tIntegrate with respect to some measure of time.
This function is a simpler version of integral where the function being
integrated takes values in the same field used to represent time.
#derivative Source
derivative :: forall event a t. IsEvent event => Field t => Ring a => (((a -> t) -> t) -> a) -> ABehavior event t -> ABehavior event a -> ABehavior event aDifferentiate with respect to some measure of time.
This function approximates the derivative using a quotient of differences at the implicit sampling interval.
The Semiring a should be a vector field over the field t. To represent
this, the user should provide a grate which lifts a division
function on t to a function on a. Simple examples where t ~ a can use
the derivative' function.
#derivative' Source
derivative' :: forall event t. IsEvent event => Field t => ABehavior event t -> ABehavior event t -> ABehavior event tDifferentiate with respect to some measure of time.
This function is a simpler version of derivative where the function being
differentiated takes values in the same field used to represent time.
#solve Source
solve :: forall t a. Field t => Semiring a => (((a -> t) -> t) -> a) -> a -> Behavior t -> (Behavior a -> Behavior a) -> Behavior aSolve a first order differential equation of the form
da/dt = f a
by integrating once (specifying the initial conditions).
For example, the exponential function with growth rate ⍺:
exp = solve' 1.0 Time.seconds (⍺ * _)
#solve2 Source
solve2 :: forall t a. Field t => Semiring a => (((a -> t) -> t) -> a) -> a -> a -> Behavior t -> (Behavior a -> Behavior a -> Behavior a) -> Behavior aSolve a second order differential equation of the form
d^2a/dt^2 = f a (da/dt)
by integrating twice (specifying the initial conditions).
For example, an (damped) oscillator:
oscillate = solve2' 1.0 0.0 Time.seconds (\x dx -> -⍺ * x - δ * dx)