From fa3a0e08dcf05101c2c2599788738080b8627323 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 12 Sep 2017 08:43:55 -0400 Subject: [PATCH] Redefine diffFPatch as a diffF function characterizing diffs. --- src/Diff.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Diff.hs b/src/Diff.hs index ae032b803..498b13ac8 100644 --- a/src/Diff.hs +++ b/src/Diff.hs @@ -68,15 +68,15 @@ diffCost = diffSum (const 1) diffPatch :: Diff syntax ann -> Maybe (Patch (TermF syntax ann (Diff syntax ann))) diffPatch diff = case unDiff diff of - Let _ body -> diffFPatch body + Let _ body -> either Just (const Nothing) (diffF body) _ -> Nothing -diffFPatch :: DiffF syntax ann a -> Maybe (Patch (TermF syntax ann a)) -diffFPatch diff = case diff of - Either (In ann (InL syntax)) -> Just (Delete (In ann syntax)) - Either (In ann (InR syntax)) -> Just (Insert (In ann syntax)) - Both (In (ann1, ann2) (Product.Pair syntax1 syntax2)) -> Just (Replace (In ann1 syntax1) (In ann2 syntax2)) - _ -> Nothing +diffF :: DiffF syntax ann a -> Either (Patch (TermF syntax ann a)) (TermF syntax (ann, ann) a) +diffF diff = case diff of + Either (In ann (InL syntax)) -> Left (Delete (In ann syntax)) + Either (In ann (InR syntax)) -> Left (Insert (In ann syntax)) + Both (In (ann1, ann2) (Product.Pair syntax1 syntax2)) -> Left (Replace (In ann1 syntax1) (In ann2 syntax2)) + Merge (In anns syntax) -> Right (In anns syntax) -- | Merge a diff using a function to provide the Term (in Maybe, to simplify recovery of the before/after state) for every Patch.