views:

371

answers:

7

Hi,

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?

+1  A: 

This is the link to the Ninety-Nine Haskell Problems which was based on the Ninety-Nine Prolog Problems. I don't know if it is exactly what you want but there might be something in there that you can use.

Kyra
A: 

When I was learning Haskell, I used Hangman as a first program. It is simple, has user and file interaction, little but some error handling etc. All of your students will have heard of it or can be taught the game quickly. I think my program ended up being around a page of code.

stonemetal
+2  A: 

The most popular example I know of is the xmonad tiling window manager. It's a real-world program that people actually use and the codebase is both pretty small and well-written (I'm told — I hardly consider myself qualified to judge most people's Haskell code).

Chuck
+1  A: 

What about cat, wc and friends?

Jason Dusek
Aren't the original ones just plain old C? Or are there some popular versions written in Haskell?
Kimmo Puputti
`main = interact wc``wc string = show [length $ lines string, length $ words string, length string ]`
applicative
`main = cat` `cat = head <$> getArgs >>= readFile >>= putStrLn`
applicative
+6  A: 

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.

Don Stewart
+1  A: 

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.

rtperson
+2  A: 

xmonad is a good idea, as others have said, if you can exhibit it to them. By the way, Simon Peyton Jones made very compelling use of xmonad in his tutorial "A Taste of Haskell" http://research.microsoft.com/en-us/um/people/simonpj/papers/haskell-tutorial/index.htm

It's less visual, of course, but I meant to be putting in a vote for Pandoc -- focussing on the incredibly simple central module, the definition of a 'document', and showing how the pure functions exported by the 'writers' and 'readers' (readMarkdown, writeLatex etc.) relate to it.

applicative