[Haskell-cafe] Perfect example
bjpop at csse.unimelb.edu.au
Thu Aug 2 20:33:23 EDT 2007
That's a tough one,
If I want a small example to show to people I usually use zipWith. It
is higher-order and lazy, and I include a discussion of "lists as
loops", which means zipWith is a loop combiner. When my audience is C
programmers I ask them to implement it in C, which is always amusing.
As an added bonus it has a lovely type signature, which can be used
as a lead-in to a discussion on types.
If I want a more "realistic" example, then I usually show people a
piece of haskell gtk code, again comparing it to C or whatever
language the audience knows. The Haskell gtk code tends to read very
nicely, and it is type safe. It also emphasises the fact that Haskell
is not only able to to "real things", but able to do them "really well".
I doubt either are "perfect", but maybe they will inspire you to
dream up something which suits your needs.
On 03/08/2007, at 5:02 AM, Jon Harrop wrote:
> Any suggestions for a perfect example that uniquely demonstrates
> the benefits
> of the Haskell language compared to other languages?
> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> OCaml for Scientists
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe