@@ -72,10 +72,11 @@ toReport dealiaser err =
7272 case err of
7373 Mismatch (MismatchInfo hint leftType rightType note) ->
7474 let
75− (subRegion, preHint) = hintToString hint
75+ (subRegion, preHint, maybePostHint) = hintToString hint
7676
7777 postHint =
7878 maybe "" (++"\n\n") note
79+ ++ maybe "" (++"\n\n") maybePostHint
7980 ++ "As I infer the type of values flowing through your program, I see a conflict\n"
8081 ++ "between these two types:\n\n"
8182 ++ P.render (P.nest 4 (P.pretty dealiaser False leftType))
@@ -111,79 +112,84 @@ toReport dealiaser err =
111112 ++ P.render (P.nest 4 (P.pretty dealiaser False tipe))
112113
113114
114−hintToString :: Hint -> (Maybe Region.Region, String)
115+hintToString :: Hint -> (Maybe Region.Region, String, Maybe String)
115116hintToString hint =
116117 case hint of
117118 CaseBranch branchNumber region ->
118119 ( Just region
119− , "The branches of this case-expression return different types of values.\n\n"
120− ++ "I noticed the mismatch in the " ++ ordinalize branchNumber ++ " branch, but go through and make sure every\n"
121− ++ "branch returns the same type of value."
120+ , "The " ++ ordinalize branchNumber ++ " branch of this `case` results in an unexpected type of value."
121+ , Just "All branches should match so that no matter which one we take, we always get\nback the same type of value."
122122 )
123123
124124 Case ->
125125 ( Nothing
126126 , "All the branches of this case-expression are consistent, but the overall\n"
127127 ++ "type does not match how it is used elsewhere."
128+ , Nothing
128129 )
129130
130131 IfBranches ->
131132 ( Nothing
132− , "The branches of this if-expression return different types of values.\n"
133− ++ "All branches must have the same return type!"
133+ , "The branches of this `if` result in different types of values."
134+ , Just "All branches should match so that no matter which one we take, we always get\nback the same type of value."
134135 )
135136
136137 MultiIfBranch branchNumber region ->
137138 ( Just region
138− , "The branches of this if-expression return different types of values.\n\n"
139− ++ "I noticed the mismatch in the " ++ ordinalize branchNumber ++ " branch, but go through and make sure every\n"
140− ++ "branch returns the same type of value."
139+ , "The " ++ ordinalize branchNumber ++ " branch of this `if` results in an unexpected type of value."
140+ , Just "All branches should match so that no matter which one we take, we always get\nback the same type of value."
141141 )
142142
143143 If ->
144144 ( Nothing
145145 , "All the branches of this if-expression are consistent, but the overall\n"
146146 ++ "type does not match how it is used elsewhere."
147+ , Nothing
147148 )
148149
149150 ListElement elementNumber region ->
150151 ( Just region
151− , "Not all elements of this list are the same type of value.\n\n"
152− ++ "I noticed the mismatch in the " ++ ordinalize elementNumber ++ " element, but go through and make sure every\n"
153− ++ "element is the same type of value."
152+ , "The " ++ ordinalize elementNumber ++ " element of this list is an unexpected type of value."
153+ , Just "All elements should be the same type of value so that we can iterate over the\nlist without running into unexpected values."
154154 )
155155
156156 List ->
157157 ( Nothing
158158 , "All the elements in this list are the same type, but the overall\n"
159159 ++ "type does not match how it is used elsewhere."
160+ , Nothing
160161 )
161162
162163 BinopLeft op region ->
163164 ( Just region
164165 , "The left argument of " ++ prettyOperator op ++ " is causing a type mismatch."
166+ , Nothing
165167 )
166168
167169 BinopRight op region ->
168170 ( Just region
169171 , "The right argument of " ++ prettyOperator op ++ " is causing a type mismatch."
172+ , Nothing
170173 )
171174
172175 Binop op ->
173176 ( Nothing
174177 , "The two arguments to " ++ prettyOperator op ++ " are fine, but the overall type of this expression\n"
175178 ++ "does not match how it is used elsewhere."
179+ , Nothing
176180 )
177181
178182 Function maybeName ->
179183 ( Nothing
180184 , "The return type of " ++ funcName maybeName ++ " is being used in unexpected ways."
185+ , Nothing
181186 )
182187
183188 UnexpectedArg maybeName index region ->
184189 ( Just region
185190 , "The " ++ ordinalize index ++ " argument to " ++ funcName maybeName
186191 ++ " has an unexpected type."
192+ , Nothing
187193 )
188194
189195 FunctionArity maybeName expected actual region ->
@@ -193,21 +199,25 @@ hintToString hint =
193199 ( Just region
194200 , capitalize (funcName maybeName) ++ " is expecting " ++ show expected
195201 ++ " argument" ++ s ++ ", but was given " ++ show actual ++ "."
202+ , Nothing
196203 )
197204
198205 BadTypeAnnotation name ->
199206 ( Nothing
200207 , "The type annotation for `" ++ name ++ "` does not match its definition."
208+ , Nothing
201209 )
202210
203211 Instance name ->
204212 ( Nothing
205213 , "Given how `" ++ name ++ "` is defined, this use will not work out."
214+ , Nothing
206215 )
207216
208217 Literal name ->
209218 ( Nothing
210219 , "This " ++ name ++ " value is being used as if it is some other type of value."
220+ , Nothing
211221 )
212222
213223 Pattern patErr ->
@@ -221,26 +231,31 @@ hintToString hint =
221231 in
222232 ( Nothing
223233 , "Problem with " ++ thing ++ " in this pattern match."
234+ , Nothing
224235 )
225236
226237 Shader ->
227238 ( Nothing
228239 , "There is some problem with this GLSL shader."
240+ , Nothing
229241 )
230242
231243 Range ->
232244 ( Nothing
233− , "The low and high members of this list range do not match."
245+ , "The low and high members of this list range are not the same type of value."
246+ , Nothing
234247 )
235248
236249 Lambda ->
237250 ( Nothing
238251 , "This anonymous function is being used in an unexpected way."
252+ , Nothing
239253 )
240254
241255 Record ->
242256 ( Nothing
243257 , "This record is being used in an unexpected way."
258+ , Nothing
244259 )
245260
246261