Last question
Tycon seems to mean "type constructor," but then what is TCon? What about Tiwara and TVar? Why is there a need to separate T and Ty?
the first.
"T" in TCon , TVar , etc. is just a marker that refers to types and that they are Type constructors. TCon takes a value of type Tycon and builds a value of type Type from this, etc. The Type constructor does not have the Ty prefix, but most likely T , to avoid confusion, the type could be defined
data Type = Tyvar Tyvar | Tycon Tycon | ...
since constructors and value types live in different namespaces, but this could open the way for more confusion.
1 type variables
- these are expressions of the type that can be replaced by expressions of another type, their identifiers begin with lowercase letters (or they can be characters that do not begin with: :).
2 Type Constructors
are type expressions that take zero or more arguments of a type expression to construct a type of type * , for example
are constructors with a null type, they take the arguments of an expression of a null type to construct a type of the form * , these are also type constants.
are unitary type constructors; they take one type expression ( * type in these examples, but unitary type constructors can accept other types of arguments).
- constructors of binary type,
is a three-dimensional type constructor that has two arguments of the form * and one of the types * -> * (thus StateT StateT :: * -> (* -> *) -> * -> * ).
3 Type of application
is an expression of the type of the form t1 t2 . It is only well formed if t2 has the form k2 , and t1 has the form k2 -> k3 (similar to applying the function). For example, StateT s is a type application, an expression of type StateT is applied to a variable of type s .
4 Type of brackets
- this is an expression of type in parentheses, which may be required for resolution or parsing of priority, otherwise it will be the same as an expression without an indirect type, for example, in
instance Monad (Either e) where ...
an expression in brackets of type (Either e) matches Either e , but parentheses are needed to distinguish it from an instance of a two-parameter class for two expressions of type Either and e . In type
StateT s ((->) a) b
parentheses around (->) a are for evaluation. (Note that the type constructor (->) is a special case not covered by the general rule that type constructors begin with uppercase letters like [] , (,) , (,,) , etc.)
Now enter the constants. These are simply type expressions that do not contain type variables, but I don't think it is formally defined anywhere. Thus, any type expression with only uppercase identifiers (including characters starting with ":") and special cases ( [] , (->) , (,) , ...) is a type constant.
- expressions of the type of one token starting with an uppercase letter (':' for characters), or special cases are type constants
- a type expression consisting entirely of type constants is a type constant