Functional reactive programming

Functional reactive programming (FRP) is a programming paradigm for reactive programming (asynchronousdataflow programming) using the building blocks of functional programming (e.g. map, reduce, filter). FRP has been used for programming graphical user interfaces (GUIs), robotics, games, and music, aiming to simplify these problems by explicitly modeling time.[citation needed]

Not to be confused with factory reset protection (FRP), a feature in some android devices.
Programming paradigms

. . . Functional reactive programming . . .

The original formulation of functional reactive programming can be found in the ICFP 97 paper Functional Reactive Animation by Conal Elliott and Paul Hudak.[1]

FRP has taken many forms since its introduction in 1997. One axis of diversity is discrete vs. continuous semantics. Another axis is how FRP systems can be changed dynamically.[2]

The earliest formulation of FRP used continuous semantics, aiming to abstract over many operational details that are not important to the meaning of a program.[3] The key properties of this formulation are:

  • Modeling values that vary over continuous time, called “behaviors” and later “signals”.
  • Modeling “events” which have occurrences at discrete points in time.
  • The system can be changed in response to events, generally termed “switching.”
  • The separation of evaluation details such as sampling rate from the reactive model.

This semantic model of FRP in side-effect free languages is typically in terms of continuous functions, and typically over time.[4]

Formulations such as Event-Driven FRP and versions of Elm prior to 0.17 require that updates are discrete and event-driven.[5] These formulations have pushed for practical FRP, focusing on semantics that have a simple API that can be implemented efficiently in a setting such as robotics or in a web-browser.[6]

In these formulations, it is common that the ideas of behaviors and events are combined into signals that always have a current value, but change discretely.[7]

It has been pointed out that the ordinary FRP model, from inputs to outputs, is poorly suited to interactive programs.[8] Lacking the ability to “run” programs within a mapping from inputs to outputs may mean one of the following solutions has to be used:

  • Create a data structure of actions which appear as the outputs. The actions must be run by an external interpreter or environment. This inherits all of the difficulties of the original stream I/O system of Haskell.[9]
  • Use Arrowized FRP and embed arrows which are capable of performing actions. The actions may also have identities, which allows them to maintain separate mutable stores for example. This is the approach taken by the Fudgets library[10] and, more generally, Monadic Stream Functions.[11]
  • The novel approach is to allow actions to be run now (in the IO monad) but defer the receipt of their results until later.[12] This makes use of an interaction between the Event and IO monads, and is compatible with a more expression-oriented FRP:

. . . Functional reactive programming . . .

This article is issued from web site Wikipedia. The original article may be a bit shortened or modified. Some links may have been modified. The text is licensed under “Creative Commons – Attribution – Sharealike” [1] and some of the text can also be licensed under the terms of the “GNU Free Documentation License” [2]. Additional terms may apply for the media files. By using this site, you agree to our Legal pages . Web links: [1] [2]

. . . Functional reactive programming . . .