[Haskell-cafe] Features of Haskell]

Bernard James POPE bjpop at csse.unimelb.edu.au
Mon Jun 5 03:35:04 EDT 2006


On Sun, Jun 04, 2006 at 11:21:23AM +0200, Niels Van Och wrote:

[snip]

> Now, in a week I have to present this work formally, and I'm a bit  
> stumped as to how I'm going to do this. I've got about 15-20 minutes,  
> so I can only discuss the major features. Right now I'm thinking about:
> 
> - Short introduction to functional programming, and Haskell in it
> - Basic syntax in a few minutes
> - Features like polymorphism, overloading, higher-order functions,  
> comprehensions, ..
> - Lazy evaluation
> - Monads: why and how?
> 
> However, I'd love to know what you think. Furthermore, do you think I  
> should include an example on the usage of Haskell, and if so, which?

Hi Niels,

15-20 mins isn't much time, so I would get straight to the point.
I wouldn't bother introducing the syntax, just explain it as you go,
to save time.

I've always liked zipWith as an example for _short_ presentations.

It is higher-order, polymorphic, and lazy. 

The classic fibonacci generator comes to mind as a "cute" example [1].
   fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

If you want to show overloading and monads then you can extend it to
zipWithM.

You'll probably want to argue why all of the features you mentioned are
important for real programming problems (not fibs). John Hughes' paper
"Why Functional Programming Matters" is a good source of material.

You might also like to argue that one of Haskell's strengths is that it
is built up from a very small core language (the lambda calculus plus let).
Higher-order functions, a good type system, and lazyness, allow many powerful
features to be included in the programmer's toolkit without having to 
change the underlying core. For example, list comprehensions are simply 
syntax sugar, rather than some fundamentally new gadget. You might say
Haskell takes abstraction and composition very seriously. 

To make your talk more even-handed, you might like to mention some of
the outstanding problems faced by Haskell programmers. For instance, 
while we seem to have a good handle on the declarative side of programming,
the operational side can be troublesome. Witness: space leaks and deepseq.
The foldl leak is a possible example:
   sum = foldl (+) 0

Now some people might complain "Sure, Haskell looks nice in theory, but
the proof is in the pudding; where's the pudding?". You might like to 
toss in a few examples of "real world" Haskell programs at the end, as a 
kind of pre-emptive strike against the non-believers. With some kind of note 
as to why Haskell was useful. Darcs and Pugs come to mind. 

As usual, all of this is qualified by the usual proviso: "It depends who
your audience is." Add salt or sugar to taste.

Hope that is of some help,
Bernie.

[1] Though, depending on your audience, this might be like playing
    "Stairway to Heaven" in a guitar shop. 


More information about the Haskell-Cafe mailing list