Hi Phil!

| > (Mark says it was very tricky to implement what Hugs does)
| 
| I can't imagine why.  Perhaps Mark can explain?

I should clarify.  Arranging for constraints that appear in the types of
constructors to show up whenever that constructor is used --- whether in
an application or a pattern match --- was not at all tricky.  Indeed, it
seems very natural, and Hugs uses exactly the same code to deal with the
two cases.

The thing that did cause me grief was the section of code to calculate
the types of selectors.  There's no fundamental reason why it should
have been so difficult though.  After all, the rule for calculating the
context of a selector is pretty straightforward, at least in theory: you
just take the union of the contexts for all the constructors to which
that selector might be applied, and use that as the selector's context.
And if you look at the final version of the code, you'll not find any
hint of the battles I fought with it.  But it did cause me problems at
the time.  I don't honestly remember the details, but I think it had
more than a little to do with the task of matching up the constraints
from different constructors so that I could form the union, further
complicated by the interaction with rank 2 polymorphism (which is not
a Haskell 98 feature anyway).

I remember Lennart suggesting at the time that I was crazy to do it
this way anyway; he had just used the rules in the report to generate
code for selectors, and then used the normal type inference mechanisms
to figure out what the type should be.  I thought I could get better
error messages doing it my way, but perhaps I should have just taken
Lennarts advice!

All the best,
Mark




Reply via email to