From 58bc4d91180ead44b10c76f308ecb50e073ad921 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Tue, 27 Nov 2018 10:15:14 -0800 Subject: [PATCH] Document the lack of expected/actual type distinction in type errors --- .../04-Debugging/src/01-General-Debugging.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/21-Hello-World/04-Debugging/src/01-General-Debugging.md b/21-Hello-World/04-Debugging/src/01-General-Debugging.md index c3ac55568..841550777 100644 --- a/21-Hello-World/04-Debugging/src/01-General-Debugging.md +++ b/21-Hello-World/04-Debugging/src/01-General-Debugging.md @@ -2,6 +2,25 @@ The following sections are tips for debugging issues that may arise in a strongly-typed language via the compiler. +## There is currently no "Actual Type / Expected Type" distinction + +In the following error... +``` + Could not match type + + A + + with type + + B + + ... rest of error ... +``` + +... one might expect `A` to be the "actual" type and `B` to be the "expected" type. However, sometimes the two are swapped, so that `A` is the "expected" type and `B` is the "actual" type. This is not desirable, but is currently how the compiler works. + +Why? Because [the compiler uses a mixture of unification and type inference to check types](https://github.com/purescript/purescript/issues/3111#issuecomment-335596641). See [purescript/purescript#3399](https://github.com/purescript/purescript/issues/3399) for more information. + ## Type Directed Search Otherwise known as "typed holes."