Simon PJ writes:
> ** I therefore PROPOSE that when pattern matching on a constructor,
> ** any context on the data type declaration is ignored.
> Yell if you dislike this; otherwise I'll just add it to the 'bugs' page.
Bleah! (Is that a loud enough yell?)
I'm happy with either of the following choices:
* Class constraints on constructors have effect everywhere (as in Hugs).
* Class constraints on constructors are eliminated (call it a typo if you must).
What you propose, I think, offers the worst of both worlds: all the
confusions of constraints on data declarations and none of the
advantages.
It may help if I explain my motivation in introducing class constraints
in data declarations. Often, a type will make no sense without the
constraints; e.g., an association list type Alist a b makes no sense
unless Eq a holds. The class constraints on data declarations were a
simple way for the user to ask the compiler to enforce this invariant.
They have compile-time effect only, no effect whatsoever on run-time
(in particular, no dictionaries should be passed).
You and some others have found this hard to accept, from which I conclude
that a compile-time language feature can be hard to understand if it is
not directly tied to run-time behaviour. Live and learn.
> (Mark says it was very tricky to implement what Hugs does)
I can't imagine why. Perhaps Mark can explain? Cheers, -- P