Your SlideShare is downloading. ×
0
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Functional Reactive Programming by Gerold Meisinger

2,009

Published on

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,009
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
34
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Functional reactive programming inSeminar Methods and Applications of Functional Programming Johannes Kepler University, Linz SS2012 by Gerold Meisinger
  • 2. Background FH Hagenberg  Digital Media FRP diploma thesis Gamedev startup ”Modern Alchemists”
  • 3. Types of programs Transformative Interactive Reactive
  • 4. What is FRP? New paradigm Time-varying values Behavior a :: Time → a Hybrid modeling  Continous-time  Discrete events React to input
  • 5. Paradigms (by Van Roy)
  • 6. Similarities Paradigms Languages Dataflow  Esterel  Common Lisp/Cells  Lustre Temporal logic  Lucid Control theory  Signal ...  Synchrone  Simulink  Modelica  ...
  • 7. Dataflow programming
  • 8. FRP implementations Classic FRP  e.g. Fran, FrTime Push-pull FRP  e.g. Reactive Arrowized FRP  e.g. Yampa, Elera
  • 9. Yampa examples Robotics GUIs Games Music synthesis Computer vision Networking ...
  • 10. Classic game programminginterface IUpdateable void update( float elapsedTime )class GameObject : IUpdateable Vector3 position Vector3 velocity void update( float elapsedTime ) position += elapsedTime * velocity
  • 11. Yampa semanticsSignal a :: Time → a Only used internallySF a b :: Signal a → Signal b SF … signal functiondata Event t = NoEvent | Event t
  • 12. Yampa design goals Continous-time & discrete events Denotative semantics Dynamic structures Higher-orderness Avoid time and space leaks ⇒ Arrow typeclass Synchronous (vs concurrent)
  • 13. Transformative f :: a → b
  • 14. Interactive
  • 15. Reactive
  • 16. Temporal
  • 17. Loop >
  • 18. Loop > Processing (black-box)
  • 19. Loop > Processing
  • 20. Loop > Processing >
  • 21. Loop > Processing > SF (BB)
  • 22. Loop > Processing > SF
  • 23. Loop > Processing > SF
  • 24. Loop > Processing > SF
  • 25. Loop > Processing > SF
  • 26. Loop > Processing > SF Mover
  • 27. Loop > Processing > Mover
  • 28. Loop > Processing > Mover
  • 29. Loop > Processing >
  • 30. Loop > Processing
  • 31. Loop > Processing
  • 32. Loop > Processing Player
  • 33. Example game: Fran
  • 34. Haskell typeclasses (by Yorgey)
  • 35. Arrow classclass Arrow a where arr :: (b → c) → a b c (<<<) :: a b c → a c d → a b d first :: a b c → a (b, d) (c, d)+ lots of arrow lawsderive combinators: second, (***), (&&&)
  • 36. Arrow combinators
  • 37. Derived Arrow combinatorssecond :: (Arrow a) ⇒ a b c → a (d, b) (d, c)second f = arr swap >>> first f >>> arr swap where swap (a, b) = (b, a)(***) :: (Arrow a) ⇒ a b c → a b c → a (b, b) (c, c)f ⋆⋆⋆ g = first f >>> second g(&&&) :: (Arrow a) ⇒ a b c → a b c → a b (c, c)f &&& g = arr (λx → (x, x)) >>> (f *** g)
  • 38. ArrowCircuitclass Arrow a ⇒ ArrowCircuit a where loop :: a (b, d) (c, d) → a b c init :: b → a b b+ even more laws
  • 39. Arrow syntax myArrow x y = proc (a, b) → do c1 ← arrow1 −< a c2 ← arrow3 <<< arrow2 −< b c ← arrow4 −< (c1, c2) rec d ← arrow5 −< (c, b, d) returnA (c, d)
  • 40. Signal function primitives
  • 41. Events
  • 42. Yampa switchswitch :: SF in (out, Event t) → (t → SF in out) → SF in out
  • 43. Yampa parallel switchpSwitch :: Functor col => (forall sf. (in → col sf → col (ext, sf))) → col (SF ext out) → SF (in, col out) (Event mng) → (col (SF ext out) → mng → SF in (col out)) → SF in (col out)
  • 44. Yampa switches immediate delayedonce switch dSwitchrecurring rSwitch drSwitchparallel broadcasted pSwitchB dpSwitchB rpSwitchB drpSwitchBparallel routed pSwitch dpSwitch rpSwitch drpSwitchcontinuation kSwitch dkSwitch
  • 45. Processingreactimate :: IO (DTime, a) –- input → (b → IO ()) –- output → SF a b → IO ()
  • 46. Game-Engine
  • 47. Ongoing research Semantics  "Garbage collecting the semantics of FRP"  "Why classic FRP does not fit interactive behavior" Performance  Causal Commutative Arrows (CCA)  Concurrency  Arrow tuples vs. signal combining
  • 48. Yampa alternatives ELM  Web runtime and IDE => converts to JavaScript http://elm-lang.org Reactive-Banana  Many examples http://apfelmus.nfshost.com
  • 49. The Endhttp://lambdor.net

×