Scoped type variables
nhn at cs.nottingham.ac.uk
Mon Dec 20 05:38:33 EST 2004
Olaf Chitil wrote:
> Hence I support Jon in that ghc should only allow those type variables
> a wider scope that have been explicitly declared with the non-Haskell
> 98 keyword "forall".
I'm inclined to support Jon and Olaf here.
I'm pretty sure there's lot of code out there that use "-fglasgow-exts"
for all sorts of reasons totally unrelated to scoped type variables.
Moreover, I suspect that type signatures for local definitions are quite
common too. I, at least, use them a fair bit. So, unless it is 100%
clear that the proposed additional way of introducing scoped type
variables really is the way to go, I would say go for the version
that breaks the fewest programs.
If nothing else, if it does turn out to really be the right way, it
would seem fairly easy to later generalize the rule, by not requiring
an explicit forall (and thus recovering the property that the current
type signature syntax is just a syntactic shorthand) than go the other
Personally, I always get a bit worried when there is too much "magic"
going on, e.g. when the meaning of syntactic constructs are stretched
in various ways in attempts to "do the right thing" tacitly. I believe
it usually better, in the long run at least, to state intentions more
explicitly. E.g., in this case, maybe it isn't such a bad idea after
all to differentiate syntactically between binding occurrences and
referring occurrences of scoped type variables?
Thus, also from this perspective it would seem that requiring an
explicit forall for introducing scoped type variables would be the
better option as it could be argued that intentions are stated a bit
more explicitly that way, although maybe not in as explicitly as
could be desired.
It is, however, unfortunate that a signature without outer foralls
no longer would be just a syntactic shorthand for signatures with the
foralls mentioned explicitly.
School of Computer Science and Information Technology
The University of Nottingham
nhn at cs.nott.ac.uk
This message has been scanned but we cannot guarantee that it and any
attachments are free from viruses or other damaging content: you are
advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
More information about the Glasgow-haskell-users