@@ -75,6 +75,7 @@ data Hint
7575 | Pattern Pattern
7676 | Shader
7777 | Lambda
78+ | Access (Maybe String) String
7879 | Record
7980 -- effect manager problems
8081 | Manager String
@@ -145,11 +146,12 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
145146 report =
146147 Report.report "TYPE MISMATCH"
147148
149+ typicalHints =
150+ Maybe.maybeToList (reasonToString =<< maybeReason)
151+
148152 cmpHint leftWords rightWords extraHints =
149153 comparisonHint localizer leftType rightType leftWords rightWords
150− ( Maybe.maybeToList (reasonToString =<< maybeReason)
151− ++ map toHint extraHints
152− )
154+ (typicalHints ++ map toHint extraHints)
153155 in
154156 case hint of
155157 CaseBranch branchNumber region ->
@@ -446,6 +448,30 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
446448 []
447449 )
448450
451+ Access (Just body) field ->
452+ let
453+ header =
454+ "`" ++ body ++ "` does not have a field named `" ++ field ++ "`."
455+ in
456+ report Nothing header $ Help.stack $
457+ [ Help.reflowParagraph $ "The type of `" ++ body ++ "` is:"
458+ , indent 4 $ dullyellow $ RenderType.toDoc localizer leftType
459+ , Help.reflowParagraph $ "Which does not contain a field named `" ++ field ++ "`."
460+ ]
461+ ++ typicalHints
462+
463+ Access Nothing field ->
464+ let
465+ header =
466+ "Cannot access a field named `" ++ field ++ "`."
467+ in
468+ report Nothing header $ Help.stack $
469+ [ Help.reflowParagraph $ "You are trying to get `" ++ field ++ "` from a value with this type:"
470+ , indent 4 $ dullyellow $ RenderType.toDoc localizer leftType
471+ , Help.reflowParagraph $ "It is not in there!"
472+ ]
473+ ++ typicalHints
474+
449475 Record ->
450476 report
451477 Nothing
@@ -653,7 +679,7 @@ reasonToString reason =
653679 (fields, maybeDeepReason) =
654680 collectFields reason
655681
656− mabyeDocs =
682+ maybeDocs =
657683 reasonToStringHelp =<< maybeDeepReason
658684
659685 starter =
@@ -667,7 +693,7 @@ reasonToString reason =
667693 _ ->
668694 Just $ "Problem at `" ++ List.intercalate "." fields ++ "`. "
669695 in
670− case (starter, mabyeDocs) of
696+ case (starter, maybeDocs) of
671697 (Nothing, Nothing) ->
672698 Nothing
673699