Skip to content


Learning Yampa and Functional Reactive Programming

Help us, help you! 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.

Update: over the time I wrote some “tutorials” myself, maybe you should start there first

  • Recommendations for learning

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

    1. A Brief Introduction to Functional Reactive Programming and Yampa (slides)
    2. Arrows, FRP, and Functional Reactive Programming (PPT)
    3. Arrows, Robots and Functional Programming: covers Yampa basics in detail (Section 3 is very domain specific and may be omitted)
    4. Functional Reactive Programming, Continued: more Yampa basics
    5. The Yampa Arcade: standard paper for games
    6. Dynamic, Interactive Virtual Environments: read chapter 3 – Time and appendix A – Functional Reactive Programming
    7. Functional Programming and 3D Games: Yampa basics in games, not very detailed though
    8. Functional Reactive Programming from First Principles: Yampa implementation details
    9. Dynamic Optimization for Functional Reactive Programming: Yampa optimization details

    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.
    • routealso 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.

    Complete list of recommended papers

    Covering FRP in general and FRP in games:

    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

    Tagged with , , .


    7 Responses

    Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

    1. taotree says

      You asked for experiences in learning AFRP so I’ll give it. I went through these papers. They were interesting but lack the most crucial thing in learning to apply AFRP–there’s no tutorial among them!

      I think the most valuable thing, and apparently non-existent, is a tutorial that walks one through building their first AFRP program. The papers are nice, but really need a tutorial.

      After writing this, I see http://lambdor.net/?p=59 that’s getting there, though something a little simpler would be nice to start. Where’s the “Hello, World” of AFRP :)

      Ah, this! http://lambdor.net/?p=34 That is great for learning. Excellent. You should link to these two posts of yours at least in trying to help people learn it.

      I think more tutorials would be of great help.

    2. Gerold Meisinger says

      done. thank you for pointing me to these great tutorials.

    3. Snark1994 says

      Your link to “Arrows, Robots and Functional Programming” is broken – http://cs.yale.edu/c2/index.php/research/project/arrows-robots-and-functional-programming still has a copy.

    4. Snark1994 says

      And “Functional Reactive Programming, continued” is now at http://www.cs.nott.ac.uk/~nhn/Talks/HW2002-FRPContinued-4up.pdf

    5. water damage clearwater says

      We are a group of volunteers and starting a new scheme in our community.
      Your website provided us with valuable info to work on. You’ve done
      an impressive job and our whole community will be grateful to you.

    6. tampa air conditioning repair says

      Hello! I just want to offer you a huge thumbs up for your
      excellent information you’ve got here on this post. I am returning
      to your blog for more soon.

    7. wine bar lakeland florida says

      After I initially left a comment I appear to have clicked the
      -Notify me when new comments are added- checkbox and from
      now on each time a comment is added I recieve 4 emails with the same comment.
      Is there a means you are able to remove me from that service?
      Many thanks!



    Some HTML is OK

    or, reply to this post via trackback.