A new version of Yampa is out (0.9.6)

Yampa is an impressive, arrowized, Functional Reactive Programming (FRP) implementation written in Haskell. We are using it to implement Android games at Keera Studios, and it has been used, among others, to implement the video game Frag (see video below). Today, a new version of Yampa sees the light. This new version includes a substantial amount of Haddock documentation and a couple new combinators.

That funny-looking Yampa

Yampa is unlike any other FRP implementation you have seen. In most FRP implementations (Elm, Reactive, Reactive-banana), you define signals in terms of other signals. This gives you a natural way of expressing what is and how it changes over time. Yampa takes FP one step further by enforcing the definition of signal functions only. It’s like Functional Functional Reactive Programming. You write signal transformers only, and the actual signals are fed at the outermost level, when you state the global simulation to be run.

To give you an example: you can’t define a ball that moves following the mouse position, but you can define a ball that moves based on the position of something and then, when you reactimate it, feed it the mouse position. This enforces a clear separation between your pure code and your IO code which, as FP goes, is precisely what you want.

In order to simplify connecting signal functions (SF) and piping several transformations, Yampa’s SFs implements the Arrow class, which also allows you to write these transformations using arrow notation. This is a choice, of course, but it does enable some great definitions:

type V2 = (Double, Double)

fallingBallPos :: V2 -> V2 -> SF () V2
fallingBallPos initialPos initialVel = proc () -> do
    vel <- (initialVel ^+^) <<^ integral -< acc
    pos <- (initialPos ^+^) <<^ integral -< vel
    returnA -< pos
  where
    acc = (0, -9.8)

See the resemblance?

What’s new?

Substantial effort has been made in this new release to document many aspects of Yampa. The most important definitions now include Haddock documentation. Up until now, users had to read the scientific publications, check the code or find examples in order to understand how Yampa worked. Because some aspects are non-trivial, it caused a lot of unnecessary confusion among users. We hope this and future releases will improve that.

Also, a new pause combinator has been included. It was used in a game to… you guessed it, pause the game.

How can I learn more about Yampa?

As a matter of fact, you couldn’t be luckier. Henrik Nilsson will give a great tutorial on Declarative Game Programming at PPDP 2014 (Current programme says Sep 9 at 14pm, but please, check their website for updates). Check the PPDP 2014 website for instructions on how to attend.

Screenshot of Yampa Breakout with SDL2 on Android

Henrik Nilsson will give a distilled tutorial on game programming in Yampa.

If you really, absolutely, definitely can’t make it to the talk, you could start by checking out some examples on github, by reading Arrows, Robots and Functional Reactive Programming, The Yampa Arcade and other publications.

Obtaining Yampa

For the faint of heart, the new version (0.9.6) is now available on hackage. If you want to contribute or keep up with changes as they come out, I recommend that you go directly to the source.

What next?

Yampa will see more tutorials, documentation, papers and improvements. A new release of Yampa will come out before October (I’d love to tell you what the new changes are, but then I would spoil the surprise, wouldn’t I?).

Who is behind this?

Credit must be given where credit is due. This release of Yampa is part of Ivan Perez’s PhD at the University of Nottingham, supervised by Henrik Nilsson.

Keera Studios is not behind this release, but merely announcing it (with permission). Additionally, the views expressed on this blog are those of Keera Studios, and are not necessarily endorsed by Henrik Nilsson or the University of Nottingham.

How can I help?

Well, you could:

  • Try Yampa! It’s really cool. Future releases will try to improve the documentation. If something is not clear, drop the maintainer a line.

  • Tell everybody about the new release: FB, Twitter, your mum, your dog…

  • Attend Henrik’s talk!!! Did we mention that there’s going to be a talk? You should go see the talk.

  • Star the github project: https://github.com/ivanperez-keera/Yampa

  • Help us make awesome games in Haskell by following and ’liking’ us on Fb/Twitter/Github/Flattr and, when the time comes, play the games!

EDIT: Added a bit more info on what actually changed in this release. Added another link to github project page. Added link to another article. Added link to issues page.

More about Keera Studios: