on master help sign in
Start wiring in type diff implementation
commitd924db7e6521e061a0a7181d370c252fd574438c authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 12 Feb 2018, 20:32 (9 years ago) parent9a55348
2 files changed+23−6
src/Reporting/Error/Type.hs+21−4 src/Type/Error.hs+2−2
src/Reporting/Error/Type.hs+21−4
@@ -309,8 +309,8 @@ toPatternReport source localizer patternRegion category tipe expected =
309309patternTypeComparison :: T.Localizer -> T.Type -> T.Type -> ( String, String, [H.Doc] ) -> H.Doc
310310patternTypeComparison localizer actual expected ( iAmSeeing, insteadOf, soHereAreSomeThoughts ) =
311311 let
312− (actualDoc, expectedDoc) =
313− error "TODO diff" localizer actual expected
312+ (actualDoc, expectedDoc, problems) =
313+ T.toDiffDocs localizer actual expected
314314 in
315315 H.stack $
316316 [ H.reflow iAmSeeing
@@ -319,6 +319,7 @@ patternTypeComparison localizer actual expected ( iAmSeeing, insteadOf, soHereAr
319319 , H.indent 4 expectedDoc
320320 ]
321321 ++ soHereAreSomeThoughts
322+ ++ map problemToHints problems
322323
323324
324325toPatternDescription :: PCategory -> String -> String
@@ -342,8 +343,8 @@ toPatternDescription category iAmTryingToMatch =
342343typeComparison :: T.Localizer -> T.Type -> T.Type -> ( String, String, [H.Doc] ) -> H.Doc
343344typeComparison localizer actual expected ( iAmSeeing, insteadOf, soHereAreSomeThoughts ) =
344345 let
345− (actualDoc, expectedDoc) =
346− error "TODO diff" localizer actual expected
346+ (actualDoc, expectedDoc, problems) =
347+ T.toDiffDocs localizer actual expected
347348 in
348349 H.stack $
349350 [ H.reflow iAmSeeing
@@ -352,6 +353,7 @@ typeComparison localizer actual expected ( iAmSeeing, insteadOf, soHereAreSomeTh
352353 , H.indent 4 expectedDoc
353354 ]
354355 ++ soHereAreSomeThoughts
356+ ++ map problemToHints problems
355357
356358
357359indentType :: T.Localizer -> T.Type -> H.Doc
@@ -387,6 +389,21 @@ toDescription category thatThingIs =
387389 OpName _ -> thatThingIs <> ":"
388390
389391
392+-- TODO be sure to avoid duplicate Problems (e.g. two instances of BadRigidVar)
393+--
394+problemToHints :: T.Problem -> H.Doc
395+problemToHints problem =
396+ case problem of
397+ T.FieldMismatch leftOnly rightOnly -> error "TODO FieldMismatch" leftOnly rightOnly
398+ T.IntFloat -> error "TODO IntFloat"
399+ T.MissingArgs numMissing -> error "TODO MissingArgs" numMissing
400+ T.ReturnMismatch -> error "TODO ReturnMismatch"
401+ T.TupleMismatch -> error "TODO TupleMismatch"
402+ T.BadFlexSuper x tipe -> error "TODO BadFlexSuper" x tipe
403+ T.BadRigidVar x tipe -> error "TODO BadRigidVar" x tipe
404+ T.BadRigidSuper x tipe -> error "TODO BadRigidSuper" x tipe
405+
406+
390407
391408-- TO EXPR REPORT
392409
src/Type/Error.hs+2−2
@@ -188,7 +188,7 @@ data Problem
188188 = FieldMismatch [N.Name] [N.Name]
189189 | IntFloat
190190 | MissingArgs Int
191− | ReturnMismatch Int Int
191+ | ReturnMismatch
192192 | TupleMismatch
193193 | BadFlexSuper N.Name Type
194194 | BadRigidVar N.Name Type
@@ -316,7 +316,7 @@ diffLambda dict ctx types1 types2 =
316316 Different
317317 (RT.lambda ctx x1 y1 zs1)
318318 (RT.lambda ctx x2 y2 zs2)
319− (Bag.append (Bag.one (ReturnMismatch numArgs1 numArgs2)) problems)
319+ (Bag.append (Bag.one ReturnMismatch) problems)
320320
321321
322322--