mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +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
|
||||
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 a b = maybeReplace $ constructAndRun a b where
|
||||
maybeReplace (Just a) = a
|
||||
|
Loading…
Reference in New Issue
Block a user