Functional Reactive Programming - HaskellWiki

url
https://wiki.haskell.org/Functional_Reactive_Programming

relevant-seeming exposition

Functional Reactive Programming (FRP) integrates time flow and compositional events into functional programming. This provides an elegant way to express computation in domains such as interactive animations, robotics, computer vision, user interfaces, and simulation.

The original formulation of Functional Reactive Programming can be found in the ICFP 97 paper Functional Reactive Animation by Conal Elliott and Paul Hudak. It introduces the following semantic functions:

at : Behaviorα → Time → α

occ : Eventα → Time × α

to provide a formal description of operations on values now commonly known as behaviors and events. But what are they? Behaviors

Traditionally a widget-based user interface is created by a series of imperative actions. First an action is invoked to create an edit widget, then additional actions can be invoked to read its current content, set it to a specific value or to assign an event callback for when the content changes. This is tedious and error-prone.

A better way to represent an edit widget's content is a time-varying value, called a behavior. The basic idea is that a time-varying value can be represented as a function of time:

newtype Behavior a =
    Behavior {
      at :: Time -> a
    }

myTodoList                :: Behavior Text
yesterday                 :: Time
myTodoList `at` yesterday :: Text

Backlinks