@@ -3,7 +3,9 @@ module Reporting.Error.Type where
4import qualified Text.PrettyPrint as P
4import qualified Text.PrettyPrint as P
6+import qualified AST.Helpers as Help
6import qualified AST.Type as Type
7import qualified AST.Type as Type
8+import qualified AST.Variable as Var
7import qualified Reporting.PrettyPrint as P
9import qualified Reporting.PrettyPrint as P
8import qualified Reporting.Region as Region
10import qualified Reporting.Region as Region
9import qualified Reporting.Report as Report
11import qualified Reporting.Report as Report
@@ -32,6 +34,9 @@ data Hint
34 | ListElement Int Region.Region
36 | ListElement Int Region.Region
37+ | BinopLeft Var.Canonical Region.Region
38+ | BinopRight Var.Canonical Region.Region
39+ | Binop Var.Canonical
@@ -135,3 +140,25 @@ hintToString hint =
135 ++ "type does not match how it is used elsewhere."
140 ++ "type does not match how it is used elsewhere."
143+ BinopLeft op region ->
145+ , "The left argument of " ++ prettyOperator op ++ " is causing a type mismatch."
148+ BinopRight op region ->
150+ , "The right argument of " ++ prettyOperator op ++ " is causing a type mismatch."
155+ , "The two arguments to " ++ prettyOperator op ++ " are fine, but the overall type of this expression\n"
156+ ++ "does not match how it is used elsewhere."
160+prettyOperator :: Var.Canonical -> String
161+prettyOperator (Var.Canonical _ opName) =
163+ then "(" ++ opName ++ ")"
164+ else "`" ++ opName ++ "`"