@@ -176,8 +176,7 @@ data Problem
176 | AnythingToBool
176 | AnythingToBool
177 | AnythingFromMaybe
177 | AnythingFromMaybe
178 | AnythingToList
178 | AnythingToList
179− | MissingArgs Int
179+ | ArityMismatch Int Int
181 | BadFlexSuper Direction Super Name.Name Type
180 | BadFlexSuper Direction Super Name.Name Type
182 | BadRigidVar Name.Name Type
181 | BadRigidVar Name.Name Type
183 | BadRigidSuper Super Name.Name Type
182 | BadRigidSuper Super Name.Name Type
@@ -255,7 +254,11 @@ toDiff localizer ctx tipe1 tipe2 =
255 <*> toDiff localizer RT.Func b y
254 <*> toDiff localizer RT.Func b y
256 <*> sequenceA (zipWith (toDiff localizer RT.Func) cs zs)
255 <*> sequenceA (zipWith (toDiff localizer RT.Func) cs zs)
258− diffLambda localizer ctx a b cs x y zs
257+ let f = toDoc localizer RT.Func in
259+ (D.dullyellow (RT.lambda ctx (f a) (f b) (map f cs)))
260+ (D.dullyellow (RT.lambda ctx (f x) (f y) (map f zs)))
261+ (Bag.one (ArityMismatch (2 + length cs) (2 + length zs)))
260 (Tuple a b Nothing, Tuple x y Nothing) ->
263 (Tuple a b Nothing, Tuple x y Nothing) ->
@@ -477,124 +480,6 @@ diffAliasedRecord localizer t1 t2 =
485−-- length cs1 /= length cs2
487−diffLambda :: L.Localizer -> RT.Context -> Type -> Type -> [Type] -> Type -> Type -> [Type] -> Diff D.Doc
488−diffLambda localizer ctx a1 b1 cs1 a2 b2 cs2 =
490− (result1:revArgs1) = reverse (a1:b1:cs1)
491− (result2:revArgs2) = reverse (a2:b2:cs2)
493− numArgs1 = length revArgs1
494− numArgs2 = length revArgs2
496− case toDiff localizer RT.Func result1 result2 of
497− Diff resultDoc1 resultDoc2 Similar ->
498− if numArgs1 < numArgs2 then
499− diffArgMismatch localizer ctx revArgs1 resultDoc1 revArgs2 resultDoc2
502− diffArgMismatch localizer ctx revArgs2 resultDoc2 revArgs1 resultDoc1
504− Diff resultDoc1 resultDoc2 (Different problems) ->
506− (a:b:cs) = reverse (resultDoc1 : map (toDoc localizer RT.Func) revArgs1)
507− (x:y:zs) = reverse (resultDoc2 : map (toDoc localizer RT.Func) revArgs2)
510− (D.dullyellow (RT.lambda ctx a b cs))
511− (D.dullyellow (RT.lambda ctx x y zs))
512− (Bag.append problems (Bag.one ReturnMismatch))
517−-- length shortRevArgs >= 2
518−-- length longRevArgs >= 2
519−-- length shortRevArgs < length longRevArgs
521−diffArgMismatch :: L.Localizer -> RT.Context -> [Type] -> D.Doc -> [Type] -> D.Doc -> Diff D.Doc
522−diffArgMismatch localizer ctx shortRevArgs shortResult longRevArgs longResult =
525− case toGreedyMatch localizer shortRevArgs longRevArgs of
526− Just (GreedyMatch shortRevArgDocs longRevArgDocs) ->
527− ( reverse (shortResult:shortRevArgDocs)
528− , reverse (longResult:longRevArgDocs)
532− case toGreedyMatch localizer (reverse shortRevArgs) (reverse longRevArgs) of
533− Just (GreedyMatch shortArgDocs longArgDocs) ->
534− ( shortArgDocs ++ [shortResult]
535− , longArgDocs ++ [longResult]
541− D.dullyellow (toDoc localizer RT.Func tipe)
543− ( reverse (shortResult : map toYellowDoc shortRevArgs)
544− , reverse (longResult : map toYellowDoc longRevArgs )
548− (RT.lambda ctx a b cs)
549− (RT.lambda ctx x y zs)
550− (Bag.one (MissingArgs (length longRevArgs - length shortRevArgs)))
554−-- GREEDY ARG MATCHER
558− GreedyMatch [D.Doc] [D.Doc]
563−-- length shorterArgs < length longerArgs
565−toGreedyMatch :: L.Localizer -> [Type] -> [Type] -> Maybe GreedyMatch
566−toGreedyMatch localizer shorterArgs longerArgs =
567− toGreedyMatchHelp localizer shorterArgs longerArgs (GreedyMatch [] [])
570−toGreedyMatchHelp :: L.Localizer -> [Type] -> [Type] -> GreedyMatch -> Maybe GreedyMatch
571−toGreedyMatchHelp localizer shorterArgs longerArgs match@(GreedyMatch shorterDocs longerDocs) =
574− D.dullyellow (toDoc localizer RT.Func tipe)
576− case (shorterArgs, longerArgs) of
578− case toDiff localizer RT.Func x y of
580− toGreedyMatchHelp localizer xs ys $
581− GreedyMatch (a:shorterDocs) (b:longerDocs)
583− Diff _ _ (Different _) ->
584− toGreedyMatchHelp localizer shorterArgs ys $
585− GreedyMatch shorterDocs (toYellowDoc y : longerDocs)
591− Just (GreedyMatch shorterDocs (map toYellowDoc longerArgs))
598-- RECORD DIFFS
483-- RECORD DIFFS