# FRP.Poll

- Package
- purescript-hyrule
- Repository
- mikesol/purescript-hyrule

### #APoll Source

`newtype APoll :: (Type -> Type) -> Type -> Type`

`newtype APoll event a`

_{}

`APoll`

is the more general type of `Poll`

, which is parameterized
over some underlying `event`

type.

Normally, you should use `Poll`

instead, but this type
can also be used with other types of events, including the ones in the
`Semantic`

module.

#### Instances

`(Functor event) => Functor (APoll event)`

`(IsEvent event, Pollable event event) => FunctorWithIndex Int (APoll event)`

`(Apply event) => Apply (APoll event)`

`(Apply event) => Applicative (APoll event)`

`(Apply event, Semigroup a) => Semigroup (APoll event a)`

`(Apply event, Monoid a) => Monoid (APoll event a)`

`(Apply event, HeytingAlgebra a) => HeytingAlgebra (APoll event a)`

`(Apply event, Semiring a) => Semiring (APoll event a)`

`(Apply event, Ring a) => Ring (APoll event a)`

`(Alt event) => Alt (APoll event)`

`(Plus event) => Plus (APoll event)`

`(IsEvent event, Pollable event event) => Pollable event (APoll event)`

`(Functor event, Compactable event, Pollable event event) => Compactable (APoll event)`

`(Functor event, Compactable event, Pollable event event) => Filterable (APoll event)`

`(IsEvent event, Plus event, Pollable event event) => IsEvent (APoll event)`

### #Pollable Source

### #createPure Source

`createPure :: forall a. ST Global (PurePollIO a)`

### #derivative Source

`derivative :: forall event a t. IsEvent event => Pollable event event => Field t => Ring a => (((a -> t) -> t) -> a) -> APoll event t -> APoll event a -> APoll event a`

Differentiate 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 => Pollable event event => Field t => APoll event t -> APoll event t -> APoll event t`

Differentiate 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.

### #gate Source

`gate :: forall event a. Pollable event event => Filterable event => APoll event Boolean -> event a -> event a`

Filter an `Event`

by the boolean value of a `Poll`

.

### #gateBy Source

`gateBy :: forall event p a. Pollable event event => Filterable event => (p -> a -> Boolean) -> APoll event p -> event a -> event a`

Sample a `Poll`

on some `Event`

by providing a predicate function.

### #integral Source

`integral :: forall event a t. IsEvent event => Pollable event event => Field t => Semiring a => (((a -> t) -> t) -> a) -> a -> APoll event t -> APoll event a -> APoll event a`

Integrate 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 => Pollable event event => Field t => t -> APoll event t -> APoll event t -> APoll event t`

Integrate 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.

### #solve Source

`solve :: forall t a. Field t => Semiring a => (((a -> t) -> t) -> a) -> a -> Poll t -> (Poll a -> Poll a) -> Poll a`

Solve 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 -> Poll t -> (Poll a -> Poll a -> Poll a) -> Poll a`

Solve 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)
```

Sample a

`Poll`

on some`Event`

.