Type Inference
Wyn supports Hindley-Milner-style type inference; in many cases explicit type annotations can be omitted. Annotations are still required in the following situations:
- Record field projection is not in general unambiguous from a
bare projection like
r.x, sormust have a type known from context or by annotation. - Sum-type constructors do not by themselves determine their sum
type —
#foo(1)is ambiguous in isolation — so the expected type must be available from context or an annotation. - Consumed parameters (see In-place Updates) must be annotated explicitly.
Top-level declarations are processed in order, and each top-level function’s type must be completely resolved at its definition site. If a top-level function uses overloaded arithmetic operators, the choice of overload cannot be influenced by later use sites — either the operand types are determined locally (e.g. by annotation) or the default arithmetic resolution applies.
Local let bindings are monomorphic; their types are not
let-generalised.