Take the 2-minute tour ×

I know several games have been coded in Haskell, but being a newbie I don't yet consider myself capable of judging quality of coding (idiomatic style, etc.)

Can anyone recommend the source of a particular game written in Haskell as a learning exercise?

(As a side note, the simpler the game, the better, really. I'd especially be thrilled if there's a well-coded RPG/roguelike.)


share|improve this question

10 Answers 10

up vote 27 down vote accepted

LambdaHack was written by an experienced Haskeller for teaching purposes, so should be well written.

share|improve this answer
Gah, it requires GTK. –  Dietrich Epp Jun 4 '09 at 22:53
The code itself is indeed quite beautiful and very instructive. Thank you for this, I'm going through it now! –  J Cooper Jun 5 '09 at 3:28
This is in response to Dietrich Epp's comment on the accepted solution. If you are trying to install LambdaHack via cabal WITHOUT GTK, you can do so by running the following command: cabal install -fcurses lambdahack –  alakra Aug 12 '11 at 16:26

I think the first-person shooter Frag is pretty cool, and the code is very interesting to look at. It's not always beautiful, but I've learned quite a bit from it, since it deals with so many of the "real" issues that my Haskell programming so far has avoided. It's also the largest example of an FRP (Functional Reactive Programming) based application that I've looked at. They use the Yampa library as a DSL to model game entities, gluing it all together with Arrows.

share|improve this answer

I just found this Game, called Nikki and The Robots that is written in Haskell, and is Open Source (ish). From their website:



(Just to clarify: The licensing is very permissive. It allows others to create their own episodes and distribute them freely or sell them. This would be very welcome. If anybody is interested in this, please talk to us. We propose to join forces and sell all our episodes through one system.)

I'm just looking over the code now, but it looks good so far.

share|improve this answer

There's a few games listed on HackageDB: packages by category # Game, and a few more on the wiki. Personally, the ones presenting more mathematical programming challenges are more interesting...

Digging through a random selection of Hackage packages, I'd say that what's currently there actually does have pretty good style, and a fair number even use advanced techniques and new features of Haskell'.

If you're looking for exemplary code of any kind: I'm always pretty happy reading GHC's library source code.

share|improve this answer
Nothing against well-written code of any kind, of course! However, I have an ulterior motive here, which is not currently being able to wrap my head around programming a game in a purely functional style. So reading examples of how to do this right also greatly interest me. –  J Cooper Jun 5 '09 at 3:31

You may be interested in Raincat, a 2D puzzle game written by a group of students at Carnegie Mellon. The game's source is available from their website.

share|improve this answer

How about Game of Life? http://www.alpheccar.org/en/posts/show/78

This is a RPG, though I don't know about the quality: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MazesOfMonad-1.0.3

share|improve this answer
For some real fun, try implementing Life with quad-based caching to speed things up: dotat.at/prog/life/hslife.hs –  ephemient Jun 4 '09 at 22:29
Game of Life is a dead link. –  mcandre Aug 14 '11 at 19:41

Being something I wrote myself I can't comment on whether it was well-written, but a while ago I wrote the beginnings of a MUD driver called Custard; I'd say that counts as an RPG. It's written in Haskell and uses mostly monadic style since that works really well for constructing MUDs. Since it uses one big state monad I've made heavy use of data-accessor; being familiar with that package will help in understanding the code.

share|improve this answer

I'm nowhere near experienced-enough to say if the code here is "exemplary," but my favorite Haskell game right now is the side-scrolling shooter, Monadius. It requires GLUT.

share|improve this answer

How relevant! I just started a Roguelike game based on Left4Dead. It's called left4deadrl.

Educational notes:

  • Uses FFI to import C code
  • Uses a Makefile to automate compilation
  • Uses a recursive game loop (render game, react to keyboard input, repeat)
  • Populates a dungeon with monsters and obstacles in random places
share|improve this answer

Although the question is now over 5 years old, I'd like to add some more recent games that are implemented in Haskell:

share|improve this answer

Your Answer


