lexically-scoped type variables in GHC 6.6

Brian Hulley brianh at metamilk.com
Thu Sep 7 14:29:30 EDT 2006


Ross Paterson wrote:
> data T = forall a. MkT [a]
>
> k :: T -> T
> k (forall a. MkT [t]) = MkT t3
> where
> t3::[a] = [t,t,t]

What was wrong with the example in the documentation?

  k :: T -> T
  k (MkT [t::a]) = MkT t3
                 where
                   t3::[a] = [t,t,t]

The type of (t) is (a) - what could possibly be simpler?

No doubt I'm missing something because the docs then go on to say "If this 
seems a little odd..." - but it doesn't. It makes perfect sense. Why 
shouldn't a pattern type signature introduce a scoped type variable? It also 
has the advantage that you can see what the type variable is supposed to 
represent without having to track down the original data declaration.

Regards, Brian.
-- 
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 



More information about the Glasgow-haskell-users mailing list