FRP.Event
- Package
- purescript-hyrule
- Repository
- mikesol/purescript-hyrule
#keepLatest Source
keepLatest :: forall a. Event (Event a) -> Event a
Flatten a nested Event
, reporting values only from the most recent
inner Event
.
#sampleOnRight Source
sampleOnRight :: forall a b. Event a -> Event (a -> b) -> Event b
Create an Event
which samples the latest values from the first event
at the times when the second event fires.
#Event Source
newtype Event a
An Event
represents a collection of discrete occurrences with associated
times. Conceptually, an Event
is a (possibly-infinite) list of values-and-times:
type Event a = List { value :: a, time :: Time }
Events are created from real events like timers or mouse clicks, and then combined using the various functions and instances provided in this module.
Events are consumed by providing a callback using the subscribe
function.
Instances
#PureEventIO Source
type PureEventIO :: Region -> Type -> Type
type PureEventIO r a = { event :: Event a, push :: a -> ST r Unit }
#PureEventIO' Source
type PureEventIO' :: Region -> Type -> Type
type PureEventIO' r a = { event :: Event a, push :: STFn1 a r Unit }
#createPure Source
createPure :: forall a r. ST r (PureEventIO r a)
Create an event and a function which supplies a value to that event in ST.
#createPureO Source
createPureO :: forall a. ST Global (PureEventIO' Global a)
Re-exports from FRP.Event.Class
#Filterable Source
class Filterable :: (Type -> Type) -> Constraint
class (Compactable f, Functor f) <= Filterable f where
Filterable
represents data structures which can be partitioned/filtered.
partitionMap
- partition a data structure based on an either predicate.partition
- partition a data structure based on boolean predicate.filterMap
- map over a data structure and filter based on a maybe.filter
- filter a data structure based on a boolean.
Laws:
Functor Relation:
filterMap identity ≡ compact
Functor Identity:
filterMap Just ≡ identity
Kleisli Composition:
filterMap (l <=< r) ≡ filterMap l <<< filterMap r
filter ≡ filterMap <<< maybeBool
filterMap p ≡ filter (isJust <<< p)
Functor Relation:
partitionMap identity ≡ separate
Functor Identity 1:
_.right <<< partitionMap Right ≡ identity
Functor Identity 2:
_.left <<< partitionMap Left ≡ identity
f <<< partition ≡ partitionMap <<< eitherBool
wheref = \{ no, yes } -> { left: no, right: yes }
f <<< partitionMap p ≡ partition (isRight <<< p)
wheref = \{ left, right } -> { no: left, yes: right}
Default implementations are provided by the following functions:
partitionDefault
partitionDefaultFilter
partitionDefaultFilterMap
partitionMapDefault
filterDefault
filterDefaultPartition
filterDefaultPartitionMap
filterMapDefault
Members
Instances
Filterable Array
Filterable Maybe
(Monoid m) => Filterable (Either m)
Filterable List
(Ord k) => Filterable (Map k)
#IsEvent Source
class IsEvent :: (Type -> Type) -> Constraint
class (Plus event, Alt event, Filterable event) <= IsEvent event where
Functions which an Event
type should implement:
once
: emits an event oncekeepLatest
flattens a nested event, reporting values only from the most recent inner event.sampleOnRight
: samples an event at the times when a second event fires.fix
: compute a fixed point, by feeding output events back in as inputs.
Members
keepLatest :: forall a. event (event a) -> event a
sampleOnRight :: forall a b. event a -> event (a -> b) -> event b
fix :: forall i. (event i -> event i) -> event i
#sampleOnRight_ Source
sampleOnRight_ :: forall event a b. IsEvent event => event a -> event b -> event a
Create an Event
which samples the latest values from the first event
at the times when the second event fires, ignoring the values produced by
the second event.