on master help sign in
Improve the missing field error message a bit

Ideal world, we’d have a string distance algorithm, so we could actually suggest fields that are close to the same name.

commite4ce75997fa0990e72207be4efa73803d829fbca authorEvan Czaplicki <info@elm-lang.org> dateWed 19 Nov 2014, 22:16 (12 years ago) parent0fe796b
1 file changed+3−1
src/Type/Unify.hs+3−1
src/Type/Unify.hs+3−1
@@ -305,7 +305,9 @@ fieldMismatchError :: Map.Map String a -> String
305305fieldMismatchError missingFields =
306306 case Map.keys missingFields of
307307 [] -> ""
308− [key] -> "Looks like one record is missing field " ++ key
308+ [key] ->
309+ "Looks like a record is missing the field '" ++ key ++ "'.\n" ++
310+ "Maybe there is a misspelling in a record access or record update?"
309311 keys ->
310312 "Looks like one record is missing fields "
311313 ++ List.intercalate ", " (init keys) ++ ", and " ++ last keys