SML# Document Version 4.0.0
19 Expressions

19.12 Type constraint expression exp : ty

This expression annotates the type ty to the expression exp. The type of exp must be either same as or more general than ty. The following shows an example.

# [] : int list;
val it = [] : int list
# 1 : intInf;
val it = 1 : intInf
# fn x => x : int;
val it = fn : int -> int
# fn x => x : ’a -> ’a;
val it = fn : [’a. (’a -> ’a) -> ’a -> ’a]

As seen in the last example, ty may contain type variables. Type variables in a type annotation are never instantiated. Unless there exists an explicit declaration of such type variables, the scope of type variables is the whole of the inner-most val declaration in which the type variables occur. See Section 23.1 for the type variable declarations and their scopes.