[Haskell] Re: GHC Error question
nr at eecs.harvard.edu
Thu Dec 7 22:06:27 EST 2006
> The analogous declaration in *Standard* ML, which gets this right, is
> fun 'a foo (x:'a) y = (x + 1, (y:'a))
Following up my own post, I thought it might be kind to explain the
arcana of the SML syntax. The explicit 'a between 'fun' and 'foo' is
SML syntax for an explicit type-lambda (or /\ or \Lambda as you prefer).
In my opinion, the syntax is a bit sneaky, but it sure is useful to be
able to bind those type variables explicitly.
Regrettably, I know of no way to write an explicit forall in an SML type.
GHC 6.6 appears to have taken the dual approach, in which the explicit
forall in the type signature magically serves also as an explicit
type-lambda in the definition of the term. Since I like to keep my
type language and term language distinct, I find this design a bit
confusing. It would be great if it were possible to write an explicit
type-lambda in the term language as well, but because Haskell does not
lexically distinguish term variables from type variables, I can't
imagine a convenient syntax.
More information about the Haskell