Interaction and ambiguous type variables

C.Reinke C.Reinke@kent.ac.uk
Thu, 03 Jul 2003 15:37:07 +0100


- use Helium at this stage, switch to full Haskell systems later?-)

- more relevant on these two lists: people have been going on
  about "teaching" Prelude/Libraries for years. I understand that GHC
  at least has seen a lot of work on making the Prelude replacable
  recently; one good way of using that would be a "teaching" package,
  optionally to replace the standard "base".

- use Hugs, but don't use (overloaded!) show at this stage?

    Prelude> :set +u
    Prelude> []
    ERROR - Cannot find "show" function for:
    *** Expression : []
    *** Of type    : [a]

    Prelude> :set -u
    Prelude> []
    []
    Prelude> ""
    []

    Main> :set +u
    Main> turn Empty
    ERROR - Cannot find "show" function for:
    *** Expression : turn Empty
    *** Of type    : Tree a

    Main> :set -u
    Main> turn Empty
    Tree_Empty

    Main> turn (Node Empty [] Empty)
    Tree_Node Tree_Empty [] Tree_Empty

- before you ask the students to interact with any Haskell
  system, give a quick demo in the lecture, explaining what
  to do with error messages, and showing examples they are
  likely to encounter?


> << Instructor:
> implement a test that checks whether a list is ordered.
> << Student:
> > ordered :: (Ord a) => [a] -> Bool

now, this is a completely different shade of grey. You ask the
students to use an overloaded operator, and the explicit type
declaration suggests that they are aware of the basics. At this
stage, polymorphic types should be understood and basic error
messages involving overloading should be explained (and
demonstrated). Otherwise, use monomorphic types and non-overloaded
operators - there is nothing wrong with beginners writing 

  orderedIntegerList :: [Integer] -> Bool

or

  orderedBy :: (a->a->Bool) -> [a] -> Bool

(with non-overloaded predicates provided by you) until they have
seen more about overloading, Haskell-style, and its interaction
with polymorphism.

> Let me close by saying that I think it's important to address this
> problem because it bites students again and again and again ...

Just for the record: things are not at all wonderful, and the
current state does bite, so any and all improvements are welcome (it
would be advisable to have a toggle option to get back to "normal").

I just wanted to point out that there are ways around some of the
problems, and that we sometimes get ahead of ourselves because the
advanced implicit features are oh so convenient and second nature to
ourselves.

Claus