[Haskell-cafe] Re: Some random newbie questions
John Hughes
rjmh at cs.chalmers.se
Mon Jan 10 04:15:57 EST 2005
I seriously considered switching frlom Hugs to GHC for my introductory
programming class this year, but in the end stayed with Hugs because of
a single feature.
I'm teaching beginning programmers, and for them at least, there is an
overwhelming volume of names to learn -- "what's that function?" is a
question they ask themselves often, as is "what's that type?". I teach
them that, whenever they see a name they don't recognise, they can find
out more about it using the :i command. This is a simple trick to learn,
that helps them understand points they've missed and catches
misapprehensions.
My students also see type classes very early. I'll bet yours will too.
Even if one is very careful to restrict the examples in lectures so as
to avoid them (which is a bind), as soon as students try out Hugs for
themselves, they will make mistakes that generate error messages
referring to type classes. No problem: the question "what's that class?"
can ALSO be answered by :i.
Now, at the beginning students have only a very rudimentary
understanding of classes. A class is a collection of types to them,
nothing more. In particular, the class definition itself is of little
use to them, since it often contains a very subtly chosen collection of
methods (just type :i Show, for example, which students do very early).
What IS useful, right from the beginning, is the list of instances. What
are Num types? Oh, integers and reals. What are Show types? Oh, pretty
much everything. Particularly when debugging "missing instance" errors,
this is just the information you need.
Unfortunately, while Hugs prints the list of instances of a class in
response to :i, GHCi does not. It only prints the class definition --
which, for my students, contains no useful information. For that reason
alone, I stuck with Hugs last year.
Of course, later in the course there is no problem in introducing GHC as
well. Students coping well are happy to learn there is a compiler
available too, while those who are struggling can stay with Hugs
throughout the course. I demonstrated GHC in order to show them
wxHaskell (which was very popular with the students), but I didn't
REQUIRE them to use it.
How about changing the behaviour of :i, Simon, so I can use GHCi
throughout next year?
John
More information about the Haskell-Cafe
mailing list