mirror of
https://github.com/github/semantic.git
synced 2025-01-06 06:46:07 +03:00
Redefine diffFPatch as a diffF function characterizing diffs.
This commit is contained in:
parent
17ebab9803
commit
fa3a0e08dc
14
src/Diff.hs
14
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 syntax ann -> Maybe (Patch (TermF syntax ann (Diff syntax ann)))
|
||||||
diffPatch diff = case unDiff diff of
|
diffPatch diff = case unDiff diff of
|
||||||
Let _ body -> diffFPatch body
|
Let _ body -> either Just (const Nothing) (diffF body)
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
diffFPatch :: DiffF syntax ann a -> Maybe (Patch (TermF syntax ann a))
|
diffF :: DiffF syntax ann a -> Either (Patch (TermF syntax ann a)) (TermF syntax (ann, ann) a)
|
||||||
diffFPatch diff = case diff of
|
diffF diff = case diff of
|
||||||
Either (In ann (InL syntax)) -> Just (Delete (In ann syntax))
|
Either (In ann (InL syntax)) -> Left (Delete (In ann syntax))
|
||||||
Either (In ann (InR syntax)) -> Just (Insert (In ann syntax))
|
Either (In ann (InR syntax)) -> Left (Insert (In ann syntax))
|
||||||
Both (In (ann1, ann2) (Product.Pair syntax1 syntax2)) -> Just (Replace (In ann1 syntax1) (In ann2 syntax2))
|
Both (In (ann1, ann2) (Product.Pair syntax1 syntax2)) -> Left (Replace (In ann1 syntax1) (In ann2 syntax2))
|
||||||
_ -> Nothing
|
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.
|
-- | Merge a diff using a function to provide the Term (in Maybe, to simplify recovery of the before/after state) for every Patch.
|
||||||
|
Loading…
Reference in New Issue
Block a user