The document introduces functional reactive programming (FRP). It discusses the history and key people in FRP, the basic abstractions of behaviors/signals and events, classic and signal-function FRP systems, implementations using continuations, applications in animations, games, audio, and robotics, ongoing work in semantics and performance, and concludes with a high-level summary of FRP.
GALNT11 as a new molecular marker in chronic lymphocytic leukemia
Introduction to Functional Reactive Programming
1. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
Introduction to Functional Reactive History of FRP
Classic and
Programming Signal-Function
FRP
Implementing FRP
Applications of
Edward Amsden FRP
Ongoing Work
Summary
PL Wonks
September 28, 2012
2. Introduction to
Overview Functional
Reactive
Programming
Edward Amsden
Introduction Introduction
History of FRP
History of FRP Classic and
Signal-Function
FRP
Classic and Signal-Function FRP Implementing FRP
Applications of
FRP
Implementing FRP Ongoing Work
Summary
Applications of FRP
Ongoing Work
Summary
3. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Introduction Implementing FRP
Applications of
FRP
Ongoing Work
Summary
4. Introduction to
Motivation Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Real programs have to deal with the real world. Classic and
Signal-Function
FRP
The real world is constrained by time.
Implementing FRP
The real world produces unpredictable inputs Applications of
to your program. FRP
Ongoing Work
Usual solution: Callbacks and event loops.
Summary
Can we extend the benefits of functional programming
to handling these characteristics of the world?
5. Introduction to
Basic Abstractions Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
FRP divides inputs into two basic classes:
Classic and
Behaviors or signals: Functions of time. Signal-Function
FRP
Events: Temporal sequences of discrete values.
Implementing FRP
An FRP language must include a means of altering or Applications of
replacing a program based on event occurrences. FRP
Ongoing Work
This is the basis of FRP’s reactivity.
Summary
These abstractions may be reified in an FRP language
or may form the basis of other abstractions, but they
must be present.
6. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
History of FRP Implementing FRP
Applications of
FRP
Ongoing Work
Summary
7. Introduction to
People Functional
Reactive
Programming
Edward Amsden
Introduction
Conal Elliott
History of FRP
Previously at Microsoft Research.
Classic and
Denotational semantics and implementations. Signal-Function
FRP
Paul Hudak
Implementing FRP
Yale University. Applications of
Applications of FRP to multimedia. FRP
Euterpea. Ongoing Work
Haskell School of Expression. Summary
Antony Courtney
Student at Yale, graduated 2004.
Arrowized FRP.
Frapp´ (FRP in Java).
e
8. Introduction to
People Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Henrik Nilsson Classic and
Signal-Function
Previously at Yale University. FRP
Collaborated on FRP with Hudak. Implementing FRP
Now at University of Nottingham. Applications of
Created Yampa, an optimized implementation of AFRP. FRP
Neil Sculthorpe Ongoing Work
Summary
Student of Nilsson at Nottingham.
Now at University of Kansas.
Creator of N-Ary FRP.
9. Introduction to
“Functional Reactive Animation” Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
Conal Elliott and Paul Hudak FRP
Implementing FRP
The original description of FRP.
Applications of
Proposed behaviors and events as abstractions. FRP
Ongoing Work
Evaluated a behavior carrying a picture
Summary
to form an animation.
10. Introduction to
“Genuinely Functional User Interfaces” Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Antony Courtney and Conal Elliott. Classic and
Signal-Function
Described a GUI toolkit based on “AFRP,” FRP
FRP formulated as an Arrow. Implementing FRP
Applications of
Proposed “signal functions” as an FRP abstraction. FRP
Signal functions are reactive constructs with events and Ongoing Work
signals as inputs and outputs. Summary
Signal functions are programs, and may be replaced
in response to events.
11. Introduction to
“Push-pull Functional Reactive Programming” Functional
Reactive
Programming
Edward Amsden
Conal Elliott Introduction
Gave denotational semantics for FRP. History of FRP
Classic and
Used to prove soundness of transformation Signal-Function
to a normal form. FRP
Implementing FRP
Normal form lifts all reactivity to top level. Applications of
Evaluate with concurrent threads: FRP
Ongoing Work
Block waiting for next event to react to.
Summary
Spin evaluating current program with time steps.
Advantage: no spinning sampling of events.
Advantage: no sampling latency in reacting to events.
Disadvantage: not a purely functional implementation.
Disadvantage: Requires kludge to merge events.
12. Introduction to
“Dynamic Optimization for Functional Reactive Functional
Reactive
Programming using Generalized Algebraic Data Programming
Edward Amsden
Types”
Introduction
History of FRP
Classic and
Signal-Function
FRP
Implementing FRP
Henrik Nilsson Applications of
FRP
Dynamically optimizing implementation of AFRP. Ongoing Work
Eliminate redundant composition introduced by Summary
switching.
13. Introduction to
“Toward Safe and Efficient Functional Reactive Functional
Reactive
Programming” Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Neil Sculthorpe
Implementing FRP
(PhD Thesis, University of Nottingham)
Applications of
FRP
Embedded AFRP in Agda
Ongoing Work
(a dependently-typed total functional language).
Summary
Introduced signal vectors as a new abstraction
to avoid embedding events in signals.
14. Introduction to
Upcoming: “Push-pull Signal Function Functional
Reactive
Functional Reactive Programming” Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Implementing FRP
Edward Amsden
Applications of
(M.S. Thesis, Rochester Institute of Technology) FRP
Using signal vectors to permit push-based evaluation Ongoing Work
Summary
of events in a signal-function FRP system.
15. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Classic and Signal-Function FRP Implementing FRP
Applications of
FRP
Ongoing Work
Summary
16. Introduction to
Families of FRP Systems Functional
Reactive
Programming
Edward Amsden
Introduction
Classic FRP History of FRP
Fran Classic and
Reactive Signal-Function
FRP
reactive-banana
Implementing FRP
elm
Applications of
Frapp´e FRP
Signal-Function FRP Ongoing Work
Fruit Summary
AFRP
Yampa
N-Ary FRP
time-flies
17. Introduction to
Classic FRP Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Events and behaviors are first-class abstractions. Signal-Function
FRP
Primitive events and behaviors must be provided by the Implementing FRP
system. Applications of
FRP
Programs are constructed by composing events and Ongoing Work
behaviors and by lifting functions and values to simple Summary
behaviors.
18. Introduction to
Signal-Function FRP Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
Signal functions are first-class abstractions. FRP
Implementing FRP
An evaluation interface provides inputs to the system
Applications of
without discrimination as to their origin. FRP
Programs are constructed by lifting functions to simple Ongoing Work
Summary
signal functions and by composing signal functions.
19. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Implementing FRP Implementing FRP
Applications of
FRP
Ongoing Work
Summary
20. Introduction to
Classic FRP Functional
Reactive
Programming
Edward Amsden
Introduction
Signals are implemented as functions from time to a History of FRP
Classic and
sample value and a new behavior. Signal-Function
FRP
This permits a behavior to throw away history and
Implementing FRP
avoid time-space leaks. Applications of
FRP
Events are represented as lazy lists of time-value pairs.
Ongoing Work
Some implementations use more complex Summary
representations of improving lists.
Either way, must have a representation of “No
occurrence yet.”
21. Introduction to
Signal-Function FRP Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal functions are represented as one or more Signal-Function
FRP
continuations. Implementing FRP
Continuations take signal sample update or event Applications of
FRP
occurrence.
Ongoing Work
Continuations produce output updates/occurrences and Summary
replacement signal function.
22. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Applications of FRP Implementing FRP
Applications of
FRP
Ongoing Work
Summary
23. Introduction to
Animations and Games Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Bouncing Balls etc. (Fran) Implementing FRP
Space Invaders (Yampa) Applications of
FRP
Frag (Yampa) Ongoing Work
Summary
24. Introduction to
Audio Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Implementing FRP
YampaSynth Applications of
FRP
Ongoing Work
Summary
25. Introduction to
Robotics Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Implementing FRP
FRob Applications of
FRP
Ongoing Work
Summary
26. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Ongoing Work Implementing FRP
Applications of
FRP
Ongoing Work
Summary
27. Introduction to
Semantics Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
Denotational semantics given for Classic FRP. (Elliott) FRP
Implementing FRP
Little work on formal semantics of signal-function FRP.
Applications of
Courtney and Elliott give informal semantics. FRP
Ongoing Work
Category-theoretic semantics for signal-function FRP?
Summary
How does composition with switch work?
28. Introduction to
Performance Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Push-based event handling should yield performance Signal-Function
FRP
increase. Implementing FRP
Dynamic optimizations (Yampa). Applications of
FRP
Static optimizations (Causal Commutative Arrows). Ongoing Work
Staged code generation? Summary
Parallelism?
29. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Summary Implementing FRP
Applications of
FRP
Ongoing Work
Summary
30. Introduction to
Summary Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Motivation: Reacting to real world
Implementing FRP
Abstractions: Behaviors/signals and events. Applications of
FRP
Implementation: Continuations.
Ongoing Work
Applications: Anything reactive. Summary
31. Introduction to
Functional
Reactive
Programming
Edward Amsden
Introduction
History of FRP
Classic and
Signal-Function
FRP
Questions? Implementing FRP
Applications of
FRP
Ongoing Work
Summary