Upcoming SlideShare
×

Introduction to Functional Reactive Programming

8,182 views

Published on

10 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
8,182
On SlideShare
0
From Embeds
0
Number of Embeds
3,264
Actions
Shares
0
94
0
Likes
10
Embeds 0
No embeds

No notes for slide

Introduction to Functional Reactive Programming

1. 1. Introduction to Functional Reactive Programming Edward Amsden IntroductionIntroduction 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. 2. Introduction toOverview Functional Reactive Programming Edward AmsdenIntroduction Introduction History of FRPHistory of FRP Classic and Signal-Function FRPClassic and Signal-Function FRP Implementing FRP Applications of FRPImplementing FRP Ongoing Work SummaryApplications of FRPOngoing WorkSummary
3. 3. Introduction to Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRPIntroduction Implementing FRP Applications of FRP Ongoing Work Summary
4. 4. Introduction toMotivation 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 beneﬁts of functional programming to handling these characteristics of the world?
5. 5. Introduction toBasic 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 reiﬁed in an FRP language or may form the basis of other abstractions, but they must be present.
6. 6. Introduction to Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRPHistory of FRP Implementing FRP Applications of FRP Ongoing Work Summary
7. 7. Introduction toPeople 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. 8. Introduction toPeople 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. 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. 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. 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. 12. Introduction to“Dynamic Optimization for Functional Reactive Functional ReactiveProgramming using Generalized Algebraic Data Programming Edward AmsdenTypes” 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. 13. Introduction to“Toward Safe and Eﬃcient Functional Reactive Functional ReactiveProgramming” 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. 14. Introduction toUpcoming: “Push-pull Signal Function Functional ReactiveFunctional 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. 15. Introduction to Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRPClassic and Signal-Function FRP Implementing FRP Applications of FRP Ongoing Work Summary
16. 16. Introduction toFamilies 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-ﬂies
17. 17. Introduction toClassic FRP Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Events and behaviors are ﬁrst-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. 18. Introduction toSignal-Function FRP Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function Signal functions are ﬁrst-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. 19. Introduction to Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRPImplementing FRP Implementing FRP Applications of FRP Ongoing Work Summary
20. 20. Introduction toClassic 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. 21. Introduction toSignal-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. 22. Introduction to Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRPApplications of FRP Implementing FRP Applications of FRP Ongoing Work Summary
23. 23. Introduction toAnimations 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. 24. Introduction toAudio Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRP Implementing FRP YampaSynth Applications of FRP Ongoing Work Summary
25. 25. Introduction toRobotics Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRP Implementing FRP FRob Applications of FRP Ongoing Work Summary
26. 26. Introduction to Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRPOngoing Work Implementing FRP Applications of FRP Ongoing Work Summary
27. 27. Introduction toSemantics 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. 28. Introduction toPerformance 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. 29. Introduction to Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRPSummary Implementing FRP Applications of FRP Ongoing Work Summary
30. 30. Introduction toSummary 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. 31. Introduction to Functional Reactive Programming Edward Amsden Introduction History of FRP Classic and Signal-Function FRPQuestions? Implementing FRP Applications of FRP Ongoing Work Summary