FRP.Event
- Package
- purescript-hyrule
- Repository
- mikesol/purescript-hyrule
#keepLatest Source
keepLatest :: forall a. Event (Event a) -> Event aFlatten a nested Event, reporting values only from the most recent
inner Event.
#sampleOnRight Source
sampleOnRight :: forall a b. Event a -> Event (a -> b) -> Event bCreate an Event which samples the latest values from the first event
at the times when the second event fires.
#Backdoor Source
type Backdoor = { bus :: Bus, create :: Create, createO :: CreateO, createPure :: CreatePure, createPureO :: CreatePureO, delay :: Delay, hot :: Hot, mailboxed :: Mailboxed, makeEvent :: MakeEvent, makeEventO :: MakeEventO, makeLemmingEvent :: MakeLemmingEvent, makeLemmingEventO :: MakeLemmingEventO, makePureEvent :: MakePureEvent, memoize :: Memoize, subscribe :: Subscribe, subscribeO :: SubscribeO, subscribePure :: SubscribePure, subscribePureO :: SubscribePureO }#CreatePureT Source
type CreatePureT = forall a r. ST r (PureEventIO r a)#CreatePureOT Source
type CreatePureOT = forall a r. ST r (PureEventIO' r a)#Event Source
newtype Event aAn 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
#MailboxedT Source
type MailboxedT = forall r a b. Ord a => Event { address :: a, payload :: b } -> ((a -> Event b) -> r) -> Event r#MakeLemmingEventOT Source
type MakeLemmingEventOT = forall a r. STFn2 Subscriber (STFn1 a r Unit) r (ST r Unit) -> Event a#PureEventIO Source
type PureEventIO :: Region -> Type -> Typetype PureEventIO r a = { event :: Event a, push :: a -> ST r Unit }
#PureEventIO' Source
type PureEventIO' :: Region -> Type -> Typetype PureEventIO' r a = { event :: Event a, push :: STFn1 a r Unit }
#Subscriber Source
newtype SubscriberConstructors
#createPure Source
createPure :: CreatePureTCreate an event and a function which supplies a value to that event in ST.
#mailboxed Source
mailboxed :: MailboxedTTakes the entire domain of a and allows for ad-hoc specialization.
#makeEvent Source
makeEvent :: MakeEventTMake an Event from a function which accepts a callback and returns an
unsubscription function.
Note: you probably want to use create instead, unless you need explicit
control over unsubscription.
#makePureEvent Source
makePureEvent :: MakePureEventTMake a pure Event from a function which accepts a callback and returns an
unsubscription function.
Note: you probably want to use create instead, unless you need explicit
control over unsubscription.
#subscribe Source
subscribe :: SubscribeTSubscribe to an Event by providing a callback.
subscribe returns a canceller function.
#subscribeO Source
subscribeO :: SubscribeOTSubscribe to an Event by providing a callback.
subscribe returns a canceller function.
Re-exports from FRP.Event.Class
#Filterable Source
class Filterable :: (Type -> Type) -> Constraintclass (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 ≡ compactFunctor Identity:
filterMap Just ≡ identityKleisli Composition:
filterMap (l <=< r) ≡ filterMap l <<< filterMap rfilter ≡ filterMap <<< maybeBoolfilterMap p ≡ filter (isJust <<< p)Functor Relation:
partitionMap identity ≡ separateFunctor Identity 1:
_.right <<< partitionMap Right ≡ identityFunctor Identity 2:
_.left <<< partitionMap Left ≡ identityf <<< partition ≡ partitionMap <<< eitherBoolwheref = \{ 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:
partitionDefaultpartitionDefaultFilterpartitionDefaultFilterMappartitionMapDefaultfilterDefaultfilterDefaultPartitionfilterDefaultPartitionMapfilterMapDefault
Members
Instances
Filterable ArrayFilterable Maybe(Monoid m) => Filterable (Either m)Filterable List(Ord k) => Filterable (Map k)
#IsEvent Source
class IsEvent :: (Type -> Type) -> Constraintclass (Alternative event, Filterable event) <= IsEvent event where
Functions which an Event type should implement:
fold: combines incoming values using the specified function, starting with the specific initial value.keepLatestflattens a nested event, reporting values only from the most recent inner event.sampleOn: samples an event at the times when a second event fires.fix: compute a fixed point, by feeding output events back in as inputs.bang: A one-shot event that happens NOW.
Members
keepLatest :: forall a. event (event a) -> event asampleOnRight :: forall a b. event a -> event (a -> b) -> event bfix :: forall i. (event i -> event i) -> event i
#sampleOnRight_ Source
sampleOnRight_ :: forall event a b. IsEvent event => event a -> event b -> event aCreate 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.