Functional Reactive Animation (Fran)
by Conal Elliott and Paul Hudak
Presentation by Daniel Bugl
Overview
- Recap: FRP
- Fran?
- Problems with Fran
- Comparison to Elm paper
- Results of papers
Recap: FRP
-
functional: pure functional programming paradigms
- reactive: applied to time-varying values

functional reactive programming
Fran?
-
Fran = functional reactive animation
- a set of data types in the programming language Haskell
- implemented in Hugs
Why Fran?
-
goal: simplify reactive animations
-
get the benefits of functional (declarative) programming
- express the "what" of an interactive animation
- automate the "how"
- possible performance optimizations in the "how"
functional reactive animation
Fran
-
behaviors: time-varying, reactive values
- most traditional values are behaviors
- e.g. time-varying images → animations
- defined via data types
-
events: sets of arbitrarily complex conditions
- e.g. mouse button presses
- specified as functions of continuous time
functional reactive animation
Data types
- behaviors
- events
lbp : Time -> Event (Event ())
- reactivity = behaviors + events
data Behavior a = Behavior (Time -> a)
Examples
bigger (sin time) circle `over`
bigger (cos time) square
- animations
- reactive animations
colorCycle t0 =
red `untilB` lbp t0 *=> \t1 ->
green `untilB` lbp t1 *=> \t2 ->
colorCycle t2
untilB : Behavior a -> Event (Behavior a)
-> Behavior a
(*=>) : Event a -> (Time -> b) -> Event b
Problems with Fran
functional reactive animation
- implicit treatment of time
- sample input data as quickly as possible
- call functions to compute events
- praised for its great expressiveness
- sounds good?
- problem: unnecessary recomputation
Solution: Elm
comparison of the two papers
-
Fran: continuous resampling of input data
→ pull approach
-
Elm: assume discrete events (values only change when events occur)
→ push approach (global event dispatcher)
Results of papers
-
Fran:
- expressive system to write reactive animations
- focus on the "what", not the "how" (declarative)
- however, performance problems with events
-
Elm:
- based on Fran
- a practical, asynchronous FRP language
- allowed efficient execution of FRP programs
(push approach)
Questions?
Global Event Dispatcher
-
Global event dispatcher
-
dispatches all events to all signal sources
-
signal sources decide if value changed or not
- if not, return:
-
dispatches all events to all signal sources
noChange v

More Examples
- events
predicate (time^2 == 5) t0
lbp t0 .|. predicate (time^2 == 5) t0
(.|.) : Event a -> Event a -> Event a
(==>) : Event a -> (a -> b) -> Event b
(*=>) : Event a -> (Time -> b) -> Event b
(-=>) : Event a -> b -> Event b
- behaviors
at : Behavior a -> Time -> a
Functional Reactive Animation (Fran)
By omnidan
Functional Reactive Animation (Fran)
- 2,315