Dcalc.TypingSourceTyping for the default calculus. Because of the error terms, we perform type inference using the classical W algorithm with union-find unification.
type typ = | TLit of A.typ_lit| TArrow of typ Pos.marked UnionFind.elem * typ Pos.marked UnionFind.elem| TTuple of typ Pos.marked UnionFind.elem list| TEnum of typ Pos.marked UnionFind.elem list| TAnyWe do not reuse Dcalc.Ast.typ because we have to include a new TAny variant. Indeed, error terms can have any type and this has to be captured by the type sytem.
Raises an error if unification cannot be performed
Operators have a single type, instead of being polymorphic with constraints. This allows us to have a simpler type system, while we argue the syntactic burden of operator annotations helps the programmer visualize the type flow in the code.
Infers the most permissive type from an expression
val typecheck_expr_top_down :
env ->
A.expr Pos.marked ->
typ Pos.marked UnionFind.elem ->
unitChecks whether the expression can be typed with the provided type
Typechecks an expression given an expected type