Questions: Bidirectional Type Checking

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A type checker encounters the expression `λx. x + 1` in isolation. A pure type inference system cannot assign it a type. Under bidirectional type checking, what makes it possible to type this expression?

AThe checker automatically infers the most general polymorphic type for the lambda
BAn expected type propagated from surrounding context switches the checker to checking mode, pushing the parameter type inward
CThe checker decomposes the lambda and infers each subexpression's type independently
DThe compiler inserts a default type annotation when the programmer omits one
Question 2 Multiple Choice

Bidirectional type checking produces better error messages than pure Hindley-Milner type inference primarily because:

AIt uses a more powerful constraint solver that catches more errors
BIt always requires explicit annotations, so errors are always at annotated sites
CErrors are reported at the exact subexpression where the actual type conflicts with the locally expected type, rather than where two distant constraints collide during unification
DIt checks each expression twice — once in each direction — catching errors earlier in compilation
Question 3 True / False

In bidirectional type checking, synthesis mode and checking mode are mutually exclusive — a given type checker uses one or the other throughout a program, not both.

TTrue
FFalse
Question 4 True / False

A lambda expression like `λx. x + 1` can be successfully type-checked in checking mode if the surrounding context provides an expected function type, even without an explicit annotation on the parameter `x`.

TTrue
FFalse
Question 5 Short Answer

Explain the difference between synthesis mode and checking mode in bidirectional type checking, and give an example of why each mode is needed.

Think about your answer, then reveal below.