Awesome Open Source
Awesome Open Source


Build Status Version on Hackage

This repository implements a generalized version of reactive programming, on top of which other variants like Yampa, Classic FRP and Reactive Values can be implemented.


$ cabal sandbox init         # Optional, but recommended
$ cabal update
$ cabal install dunai


Dunai currently supports GHC versions 7.6.3 to 8.8.2.


To test Dunai:

  • Use embed :: MSF m a b -> [a] -> m [b] to collect a list with the results.

  • Use embed_ :: MSF m a () -> [a] -> m () to perform side effects without collecting the results.

  • Use reactimate :: MSF m () () -> m () when data is collected/provided by the MSF itself.

ghci> import Data.MonadicStreamFunction
ghci> embed (arr (+1)) [1,2,3,4,5]
ghci> embed_ (arr (+1) >>> liftS print) [1,2,3,4,5]
ghci> reactimate (arrM_ getLine >>> arr reverse >>> liftS putStrLn)
Haskell is awesome
emosewa si lleksaH

Further references


The best introduction to the fundamentals of Monadic Stream Functions is:

The following papers are also related to MSFs:



Structure and internals.

This project is split in three parts:

  • Dunai: a reactive library that combines monads and arrows.
  • BearRiver: Yampa implemented on top of Dunai.
  • Examples: ballbounce
    • sample applications that work both on traditional Yampa and BearRiver.

We need to add examples of apps written in classic FRP, reactive values, etc. A new game, in honor of Paul Hudak, has been designed to work best with this library. The game haskanoid works both with Yampa and with Bearriver/dunai.


Performance is ok, simpler games will be playable without further optimisations. This uses unaccelerated SDL 1.2. The speed is comparable to Yampa's.

2016-05-09 15:29:41 [email protected]:~/Projects/PhD/Yampa/yampa-clocks-dunai$ ./.cabal-sandbox/bin/haskanoid

Performance report :: Time per frame: 13.88ms, FPS: 72.04610951008645, Total running time: 1447
Performance report :: Time per frame: 16.46ms, FPS: 60.75334143377886, Total running time: 3093
Performance report :: Time per frame: 17.48ms, FPS: 57.20823798627002, Total running time: 4841
Performance report :: Time per frame: 19.56ms, FPS: 51.12474437627812, Total running time: 6797
Performance report :: Time per frame: 19.96ms, FPS: 50.100200400801604, Total running time: 8793
Performance report :: Time per frame: 19.44ms, FPS: 51.440329218106996, Total running time: 10737

It runs almost in constant memory, with about 50% more memory consumption than with Yampa (200k for Yampa and 300K for dunai/bearriver). There is very minor leaking, probably we can fix that with seq.

We have obtained different figures tracking different modules. In the paper, we provided figures for the whole game, but we need to run newer reliable benchmarks including every module and only things that live in FRP.Yampa, FRP.BearRiver and Data.MonadicStreamFunction.

You can try it with:

git clone
cd haskanoid/
cabal sandbox init
cabal install -f-wiimote -f-kinect -fbearriver haskanoid/

Related Projects




We follow:

Feel free to open new issues. We are looking for:

  • Unexplored ways of using MSFs.
  • Other games or applications that use MSFs (including but not limited to Yampa games).
  • Fixes. The syntax and behaviour are still experimental. If something breaks/sounds strange, please open an issue.

About the name

Dunai (aka. Danube, or Дунай) is one of the main rivers in Europe, originating in Germany and touching Austria, Slovakia, Hungary, Croatia, Serbia, Romania, Bulgaria, Moldova and Ukraine.

Other FRP libraries, like Yampa, are named after rivers. Dunai has been chosen due to the authors' relation with some of the countries it passes through, and knowing that this library has helped unite otherwise very different people from different backgrounds.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
haskell (1,565
game (1,000
functional-programming (464
games (145
monad (59
frp (56
functional-reactive-programming (44
haskell-library (24
abstraction (22

Find Open Source By Browsing 7,000 Topics Across 59 Categories