map and fmap
John Hughes
rjmh at cs.chalmers.se
Fri Aug 18 08:17:31 EDT 2006
Jon Fairbairn wrote:
> ...
>
>The "beginners' prelude" would then consist of several
>modules that provided classless versions of the troublesome
>overloaded functions, each to be replaced by the real thing
>when the source of the trouble had finally been taught. So
>what I'm proposing doesn't avoid your objection about a
>discontinuity -- in fact it introduces more, but my hope
>would be that several small discontinuities rather than one
>big one would be sufficiently little trouble. ... folk who only got as far as doing
>arithmetic on Integers and Rationals with some simple stuff
>on Lists could go on using the simplest beginners' prelude
>indefinitely.
>
Hmmm.
I clearly don't teach the way you do. "Folk who only get as far as doing
arithmetic on Integers and Rationals with some simple stuff on Lists"
doesn't include my students at the end of lecture 1! (That is, I start with
different material).
I actually don't see much problem caused by the overloading of numbers,
where teaching is concerned. Yes, it means that students see classes
very early--
in error messages at least--but it's enough to tell them that Num a means a
should be some kind of number (Integer or Double in my course). This is
a small cost at the time I have to explain it. The good thing about
doing so is
that students start getting used to the idea of classes, and to
distinguishing a
class from a type, so that when I later introduce Eq and Ord constraints
(which are very hard to get away from in reusable code), the concept of a
class constraint is already familiar. Later on, when I show them wxHaskell,
there are classes everywhere, but the basic idea is by then quite familiar.
So I'm dubious that your idea of a beginners' prelude would really work
better,
even for teaching beginners! Type classes are such an essential part of
Haskell
that even beginners need to learn about them... but constructor classes
(Monad,
Functor etc) are another kettle of fish altogether.
John
More information about the Haskell-prime
mailing list