A type variable is a way to refer to an unspecified type or set of types in Haskell type signatures. Type variables ordinarily will be equal to themselves throughout a type signature. Let us consider some examples:
id :: a -> a
The only type variable, a, occurs twice, once as an argument, once as a result. The type variable is parametrically polymorphic and could be strictly anything.
(+) :: Num a => a -> a -> a
Only one type variable named a, again. a is constrained to requiring an instance of Num. Two arguments of the same type a and one result.
Type variables only appear in type signatures. (that may seem obvious)
A type variable is a variable used in a type signatures such as a in f :: a -> a.
A type variable is a lower case letter such as a used in a type signature.
The only type variable,
a
, occurs twice, once as an argument, once as a result. The type variable is parametrically polymorphic and could be strictly anything.Only one type variable named
a
, again.a
is constrained to requiring an instance of Num. Two arguments of the same typea
and one result.a
inf :: a -> a
.a
used in a type signature.