user interface - How are events who lead to UI changes handled/modelled with functional reactive programming? -


i've looked functional reactive programming, coming imperative world fail understand how functional language might react user event , adapt data , ui reflect necessary changes.

i've taken quick @ examples elm homepage, far understand allows describe (changing) output function of (changing) input (i.e. "draw rectangle @ mouse position" automatically updated , redrawn).

however, single events trigger action? example take usual app allows edit document in window. window has "new" button (or menu item) opens window instance. how work? appreciate if explain concept behind it.

the short answer is: frp inherently not purely functional, in general reactions actual external environment imperative in character. below describe "pure" approach frp, there more efficient more "imperative" approaches based on continuations.

• frp attempt declaratively deal time.

• behaviors functions of time.

◦ behavior has specific value in each instant.

• events sets of (time, value) pairs.

◦ i.e. organised streams of actions.

• 2 problems

◦ behaviors / events defined when don’t depend on future

◦ efficiency: minimize overhead

• frp synchronous: possible set events happen @ same time, , continuous: behaviors can have details @ arbitrary time resolution.

◦ although results sampled, there’s no fixed (minimal) time step specifying behavior.

◦ asynchrony refers various ideas ask people mean.

• forcing lazy list (stream) of events wait till event arrives.

• scanning through event list since beginning of time till current time, each time evaluate behavior – wasteful wrt. time&space. producing stream of behaviors stream of time allows forget events in past.

• next optimization pair user actions sampling times. action nothing corresponds sampling time when nothing happens.

• turning behaviors , events functions of time input-output streams similar optimizing interesction of ordered lists o(m n) o(m + n) time.

• can in turn define events in terms of (optional, maybe) behaviors, happening @ points in time rather varying on intervals of time.

• looks stream processing.

i discuss frp in a lecture on zippers, adaptive programming, frp , guis ocaml-centric.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -