This thesis presents the implementation of bidirectional typing in the programming language Millet. The existing implementation is based on the Hindley–Milner type system, which infers types by generating type equations and solving them through unification. Bidirectional typing replaces this approach with two distinct procedures: type synthesis, which derives a type from an expression, and type checking, which checks an expression against an expected type. The thesis describes the adaptation of the type system and the implementation of the core procedures for type synthesis and checking. Particular attention is given to expressions, function abstractions and applications. The thesis also examines how this change affects the need for explicit type annotations and the reporting of typing errors. The results show that the bidirectional approach enables more precise reporting of certain typing errors. Whereas the original implementation reported most type mismatches as unification failures, the new implementation provides more specific error messages for selected cases, identifying the construct in which the error occurred.
|