Hi Alex,
| Further to discussion on the StdHask site, and (of all places) ghc-bugs,
| I remain concerned about the program-breaking proposal to have typesigs
| scope over equation groups, thereby binding any type variable occurrences
| in local signatures. But I agree with the need to add this expressivity.
| Surely it's possible to do this by a purely conservative
| extension, though?
I think the way that Hugs 1.3c handles it would meet your goals. All that
it requires is a strict extension to the syntax for patterns to allow type
annotations. These can be useful in their own right, but also can be
applied
to problems like the one that you gave:
f :: [a] -> a -> [a]
f ((x::a):xs) y = g y
where
g :: a -> [a]
g q = [x,q]
The only change I've made here is to replace "x" on the left hand side of
the definition for f with "(x::a)". As a result, the type variable "a"
will be in scope when the signature of g is encountered, and so will not
be subjected to the usual, implicit universal quantification. I like this
approach because it is a strict extension, it has other (and more
interesting)
uses than the one shown here, and it has some history (in SML, for example
...
I didn't invent it). In recent discussions with Simon, we discovered that
this approach also works better if existential types are included in the
language.
All the best,
Mark