You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
joins nested events, such that an event occurs when both inner and outer events occur at the same time
Efficiently combining multiple events into a single one: merge
efficiently combines multiple events into a single one
supports input events with different value types
input: collections of events, indexed by a key, where the type of the event is determined by the key
output: event that fires whenever one or more input events fired, with their values.
Efficiently deliviering an event to many consumers: fan
should be partially applied!
for performance, since assignment of events to consumers happens once and not separately for each consumer
Implementing FRP-based frameworks
Networks should be build in a type with an instance for MonadReflexHost
To use the Spider implemenation, import Reflex.Spider and use runSpiderHost
create events with newEventWithTrigger.
subscribe for events using `subscribeEvent`
use fireEventsAndRead to notify the network whenever one or more input events changed
you can read the new output events here, which you should use to update the outside world
fireEventsAndRead should be called in the event loop, whenever one input event changed
The Spider Implementation
The FRP network forms a directed graph: nodes are FRP objects (events, behaviors, etc) and edges represent dependencies
To run the frame, spider does a breadth-first traversal of the graph
Each entry in the network has an associated height:
Entries with a lower height may never depend on entries with a greater height.
This means that when entries of a given height are evaluated, all entries of previous heights have already been processed.
Notes on weak references
If possible, place on IORef since IORefs aren’t optimized away
If placing a weak reference on a constructed haskell type:
make sure that the value is in WHNF before adding the weak ref, since forcing sometimes makes the weak ref invalid
hide the constructor from GHC via a NOINLINE function, or GHC will optimize the constructor away and directly use the parts
to keep the value itself alive, do not store it in unpacked fields (since that again will eliminate the constructor)