Scoped type variables

Ross Paterson ross at soi.city.ac.uk
Wed Feb 8 06:03:01 EST 2006


On Tue, Feb 07, 2006 at 08:15:19PM +0000, Ben Rudiak-Gould wrote:
> Simon PJ thinks that Haskell' should include scoped type variables, and I 
> tend to agree. But I'm unhappy with one aspect of the way they're 
> implemented in GHC. What I don't like is that given a signature like
> 
>     x :: a -> a
> 
> there's no way to tell, looking at it in isolation, whether a is free or 
> bound in the type.

A second problem with GHC's provision of scoped type variables is the
confusing variety of ways of doing it.  Some of them address the same
problem that partial type signatures aim at (e.g. by allowing signatures
for parts of arguments and/or the result of functions).  Partial type
signatures may well not be ready in time for Haskell', but we should
still try to avoid overlap.

I think we should "do the simplest thing that could possibly work",
and then see if we really need more.  By "work", I mean a compatible
extension of H98 that makes it possible to add type signatures for
local bindings (which isn't always possible in H98).  How about:

 * no implicit binding of type variables: to bind, use "forall".

 * pattern type annotations allowed only at the top level of pattern
   bindings and lambda arguments (not on sub-patterns or arguments of
   function bindings).

 * no result type annotations (except on pattern bindings, where they're
   equivalent to top-level pattern type annotations).



More information about the Haskell-prime mailing list