1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 21:16:12 +03:00

🔥 ByKey operations.

This commit is contained in:
Rob Rix 2016-07-12 23:26:14 -04:00
parent 7370e927b8
commit c3f060d65b
2 changed files with 0 additions and 6 deletions

View File

@ -2,7 +2,6 @@ module Interpreter (Comparable, DiffConstructor, diffTerms) where
import Algorithm
import Category
import Data.Align
import Data.Align.Generic
import Data.Functor.Foldable
import Data.Functor.Both
@ -37,7 +36,6 @@ constructAndRun construct comparable cost t1 t2
| otherwise =
run construct comparable cost $ algorithm a b where
algorithm (Indexed a') (Indexed b') = wrap $! ByIndex a' b' (annotate . Indexed)
algorithm (Keyed a') (Keyed b') = wrap $! ByKey a' b' (annotate . Keyed)
algorithm (Leaf a') (Leaf b') | a' == b' = annotate $ Leaf b'
algorithm a' b' = wrap $! Recursive (cofree (annotation1 :< a')) (cofree (annotation2 :< b')) pure
(annotation1 :< a, annotation2 :< b) = (runCofree t1, runCofree t2)
@ -55,8 +53,6 @@ run construct comparable cost algorithm = case runFree algorithm of
diffThese = these (pure . Delete) (pure . Insert) (diffTerms construct comparable cost)
Free (ByKey a b f) -> run construct comparable cost $ f byKey where byKey = alignWith (these (pure . Delete) (pure . Insert) (diffTerms construct comparable cost)) a b
Free (ByIndex a b f) -> run construct comparable cost . f $ ses (constructAndRun construct comparable cost) cost a b
Free (ByRandomWalkSimilarity a b f) -> run construct comparable cost . f $ rws (constructAndRun construct comparable cost) getLabel a b

View File

@ -2,7 +2,6 @@ module Operation where
import Prologue
import Diff
import Data.OrderedMap
import Term
-- | A single step in a diffing algorithm.
@ -13,7 +12,6 @@ data Operation
-- | Recursively diff two terms and pass the result to the continuation.
= Recursive (Term a annotation) (Term a annotation) (Diff a annotation -> f)
-- | Diff two dictionaries and pass the result to the continuation.
| ByKey (OrderedMap Text (Term a annotation)) (OrderedMap Text (Term a annotation)) (OrderedMap Text (Diff a annotation) -> f)
-- | Diff two arrays and pass the result to the continuation.
| ByIndex [Term a annotation] [Term a annotation] ([Diff a annotation] -> f)
| ByRandomWalkSimilarity [Term a annotation] [Term a annotation] ([Diff a annotation] -> f)