[Haskell-cafe] ScopedTypeVariables

Evan Laforge qdunkan at gmail.com
Tue Aug 6 20:46:26 CEST 2013


Occasionally I have to explicitly add a type annotation, either for
clarity or to help choose a typeclass instance.  Usually top-level
type annotations take care of this, but sometimes it's convenient to
only annotate a certain value, e.g. one argument of a lambda.

I've noticed that while vanilla haskell is happy to allow me to put
type annotations on variables where they are used (e.g. '\x -> f (x ::
T)'), if I put it on the variable where it is bound (e.g. '\(x :: T)
-> f x'), it wants me to turn on ScopedTypeVariables.

I think ScopedTypeVariables is a nice extension and I'm sure it comes
from a perfectly respectable family and all, but it feels like
annotations on arguments comes in as a side-effect.

Would it make sense to split it into a separate extension like
TypesOnArguments so I can more accurately express my deviation from
haskell2010 orthodoxy?  Or is there some deeper tie between scoped
type variables and annotations on arguments?

Now that I think of it, it seems inconsistent that 'x :: A -> B; x a =
...' is valid, but 'x = \(a :: A) -> (...) :: B' is not.  Doesn't the
former desugar to the latter?

And what about getting ScopedTypeVariables into haskell prime?  As far
as I know everyone loves it, or at least no one actually hates it :)




More information about the Haskell-Cafe mailing list