[Haskell-cafe] Where does ~> come from?
simonpj at microsoft.com
Tue Mar 11 05:15:06 EDT 2008
| I think, it won’t find it. As Cale said, it’s a type variable. It’s like
| the “a” in the following definition:
| data T a = T a a
| I think, Conal Elliott used an operator type variable in order to make his
| code more readable. The (~>) is a type parameter which stands for an arrow
I've been thinking for some time that GHC's current lexicographic choice about type variables, although consistent, is an mistake. (I say "GHC" because Haskell 98 does not have operator symbols in the type namespace at all.)
As of today,
a is a type variable
T is a type constructor
~> is a type variable
:~> is a type constructor
That's consistent with the syntax for data constructors. But it's a pain. For a start (->) is a type constructor not a type variable. More important, it's just so right to declare a sum type like this
data a + b = Left a | Right b
f :: a -> (a+b)
f = ...
But GHC currently makes you say
data a :+: b = Left a | Right b
f :: a -> (a:+:b)
I hate those colons! The obvious thing is to say that
operator symbols (of all kinds) are type constructors,
and only alphabetic things are type variables.
That's less consistent, but I think it might be more useful.
I was provoked to type this by realising that Conal, at least, is using an operator symbol (~>) as a type variable. I wonder how bad it'd be in this case to have to use an alphabetic name (backquotes still work).
Just flying a kite here -- this isn't high on my list. But the more we do at the type level, the more we want type expressions that look sensible.
More information about the Haskell-Cafe