mirror of
https://github.com/github/semantic.git
synced 2024-12-26 00:12:29 +03:00
Interpret ByKey algorithms.
This commit is contained in:
parent
213d8fbd55
commit
a7545ed749
@ -29,6 +29,12 @@ run (Free (Recursive a b f)) = run . f $ recur a b where
|
|||||||
maybeInterpret (Just a) (Just b) = interpret a b
|
maybeInterpret (Just a) (Just b) = interpret a b
|
||||||
recur _ _ = Pure $ Replace a b
|
recur _ _ = Pure $ Replace a b
|
||||||
|
|
||||||
|
run (Free (ByKey a b f)) = run $ f byKey where
|
||||||
|
byKey = unions [ deleted, inserted, patched ]
|
||||||
|
deleted = (Pure . Delete) <$> difference a b
|
||||||
|
inserted = (Pure . Insert) <$> difference b a
|
||||||
|
patched = intersectionWith interpret a b
|
||||||
|
|
||||||
interpret :: Term a Info -> Term a Info -> Diff a
|
interpret :: Term a Info -> Term a Info -> Diff a
|
||||||
interpret a b = maybeReplace $ constructAndRun a b where
|
interpret a b = maybeReplace $ constructAndRun a b where
|
||||||
maybeReplace (Just a) = a
|
maybeReplace (Just a) = a
|
||||||
|
Loading…
Reference in New Issue
Block a user