Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nice small simple real life programming example in Haskell? [closed]

I know, I might be asking much, but does any one know of some nice little programming examples / libraries for Haskell.

For a 'introduction to programming' course I want to show that Haskell is more than a 'little script language to sort numbers'.

I already found a Quake clone (Real world Haskell programming) which is impressive, but too complex for the students to play around with.

Do you have an idea? Maybe something with graphics or interaction with a web service? Something suitable for first year cs students.

Thanks for your intput!

[update]

Or maybe you know a 'fun' library?

like image 958
Framester Avatar asked Jun 24 '10 16:06

Framester


People also ask

How do you say hello world in Haskell?

main = putStrLn "Hello, World!" module Main where main = putStrLn "Hello, World!" module Main where main = putStrLn "Hello, World!"

Is Haskell elegant?

Haskell provides an elegant, concise and safe way to write your programs. Programs will not crash unexpectedly, nor produce strangely garbled output.

Why is Haskell so powerful?

Haskell's design is centered around pure functions and immutable data. Over and over, these features have proven essential for writing correct software. Managing global state, mutable data, and side effects is error-prone, and Haskell gives the programmer all the tools to avoid or minimize these sources of complexity.


2 Answers

Dig around on http://hackage.haskell.org -- there are 2200+ libraries and programs there, many in the games section, in particular, where designed for teaching. As was this jpeg encoder, or this nice mp3 decoder.

In terms of practicality, the core of xmonad is concise, pure and used by thousands of people every day.

like image 59
Don Stewart Avatar answered Sep 22 '22 01:09

Don Stewart


I'm going to put in a plug for Star Rover and Freekick, for a few reasons:

  • They're games, so they have that "wow" factor for students (albeit with fairly limited playability right now -- Freekick essentially plays against itself, and if you can kill an enemy in Star Rover, you're a better gamer than I am).
  • The developer wrote a very informative blog that will help students get an idea about the learning curve.
  • Both games some very simple code fragments that students will be able to understand immediately: the Tree module, for instance, or the radians-to-degrees conversion function.
  • Library dependencies are relatively minimal: OpenGL and SDL, mostly.

Good luck, and hope this helps.

like image 22
rtperson Avatar answered Sep 26 '22 01:09

rtperson