Learning Yampa and Functional Reactive Programming

This blog post was originally written back in 2010-06-13

If you are just starting to learn Yampa, please share your experiences! This post just covers my personal opinion on how to tackle Yampa, maybe you have additional or different recommendations.

Recommendations for learning

I recommend reading the following papers/presentations to learn Yampa and FRP in general:

Understanding FRP

I think to learn FRP (for games) you have to especially understand the following aspects:

  • Signals make time omnipresent

  • Systems are built with Signal Functions (SF a b)

  • FRP is implemented in standard Haskell

  • Arrow notation makes using FRP convenient and more readable

  • Signal functions diagrams look just mirrored to the actual arrow notation code :)

  • The signal function systems need to be updated somehow – usually via reactimate

  • reactimate divides the programm into input IO (sense), the signal function (SF) and output IO (actuate)

  • Switches allow dynamic changes of the reactive system. Note that in Yampa signal functions are continuation-based so they “switch into” a new signal function.

  • To handle dynamic game object collections use the delayed parallel switch (dpSwitch) signal function

  • Input events are propagated to the objects via route

  • route also reasons about the whole object collection to produce logical events (f.e. hit detection)

  • killOrSpawn collects all kill and spawn events into one big function composition (insertion/deletion) which is applied to the object collection

  • In the Space Invaders example gameCore :: IL Object -> SF (GameInput, IL ObjOutput) (IL ObjOutput) is actually embedded in the function core :: ... -> SF GameInput (IL ObjOutput) which acts as the intermediate between sense and actuate (this is not mentioned in the Yampa Arcade paper)

List of discarded papers

The reason for discarding was mostly because they are too old, too theoretical or off-topic from games:

  • A Functional Reactive Animation Of A Lift Using Fran

  • A Language for Declarative Robotic Programming

  • Crafting Game-Models Using Reactive System Design

  • Event-Driven FRP

  • FrTime – A Language for Reactive Programs

  • Functional Reactive Animation

  • Functional Reactive Programming for Real-Time Reactive Systems

  • Genuinely Functional User Interfaces

  • Interactive Functional Objects in Clean

  • Modelling Reactive Multimedia – Events and Behaviours

  • Modular Domain Specific Languages and Tools

  • Prototyping Real-Time Vision Systems

  • Reactive Multimedia Documents in a Functional Framework

  • Real-Time FRP