mirror of
https://github.com/github/semantic.git
synced 2024-12-11 08:45:48 +03:00
Rename copy to merge.
This commit is contained in:
parent
a140d2f4c4
commit
f4e475104f
@ -86,7 +86,7 @@ instance Show term => Show1 (AlgorithmF term diff) where
|
||||
-- | Diff two terms based on their generic Diffable instances. If the terms are not diffable
|
||||
-- (represented by a Nothing diff returned from algorithmFor) replace one term with another.
|
||||
algorithmForTerms :: (Functor f, Diffable f) => Term f a -> Term f a -> Algorithm (Term f a) (Diff f a) (Diff f a)
|
||||
algorithmForTerms t1@(Term (In ann1 f1)) t2@(Term (In ann2 f2)) = fromMaybe (byReplacing t1 t2) (fmap (copy (ann1, ann2)) <$> algorithmFor f1 f2)
|
||||
algorithmForTerms t1@(Term (In ann1 f1)) t2@(Term (In ann2 f2)) = fromMaybe (byReplacing t1 t2) (fmap (merge (ann1, ann2)) <$> algorithmFor f1 f2)
|
||||
|
||||
|
||||
-- | A type class for determining what algorithm to use for diffing two terms.
|
||||
|
@ -122,8 +122,8 @@ deleting :: Functor syntax => Term syntax ann -> Diff syntax ann
|
||||
deleting = cata (Diff . Let mempty . Either . hoistTermF InL)
|
||||
|
||||
|
||||
copy :: (ann, ann) -> syntax (Diff syntax ann) -> Diff syntax ann
|
||||
copy = (Diff .) . (Let mempty .) . (Merge .) . In
|
||||
merge :: (ann, ann) -> syntax (Diff syntax ann) -> Diff syntax ann
|
||||
merge = (Diff .) . (Let mempty .) . (Merge .) . In
|
||||
|
||||
var :: Metavar -> Diff syntax ann
|
||||
var = Diff . Var
|
||||
|
@ -49,7 +49,7 @@ diffTermsWith refine comparable (Join (a, b)) = runFreer decompose (diff a b)
|
||||
decompose step = case step of
|
||||
Algorithm.Diff t1 t2 -> refine t1 t2
|
||||
Linear t1 t2 -> case galignWith diffThese (unwrap t1) (unwrap t2) of
|
||||
Just result -> copy (extract t1, extract t2) <$> sequenceA result
|
||||
Just result -> merge (extract t1, extract t2) <$> sequenceA result
|
||||
_ -> byReplacing t1 t2
|
||||
RWS as bs -> traverse diffThese (rws (editDistanceUpTo defaultM) comparable as bs)
|
||||
Delete a -> pure (deleting a)
|
||||
@ -104,7 +104,7 @@ algorithmWithTerms t1 t2 = case (unwrap t1, unwrap t2) of
|
||||
<*> byRWS bodyA bodyB
|
||||
_ -> linearly t1 t2
|
||||
where
|
||||
annotate = copy (extract t1, extract t2)
|
||||
annotate = merge (extract t1, extract t2)
|
||||
|
||||
|
||||
-- | Test whether two terms are comparable by their Category.
|
||||
@ -129,4 +129,4 @@ editDistanceUpTo m = these termSize termSize (\ a b -> diffCost m (approximateDi
|
||||
Let _ (Merge body) -> sum (fmap ($ pred m) body)
|
||||
Let _ body -> succ (sum (fmap ($ pred m) body))
|
||||
Var v -> maybe 0 ($ pred m) (envLookup v env)
|
||||
approximateDiff a b = maybe (replacing a b) (copy (extract a, extract b)) (galignWith (these deleting inserting approximateDiff) (unwrap a) (unwrap b))
|
||||
approximateDiff a b = maybe (replacing a b) (merge (extract a, extract b)) (galignWith (these deleting inserting approximateDiff) (unwrap a) (unwrap b))
|
||||
|
Loading…
Reference in New Issue
Block a user