mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Unpack the annotations &c inline.
This commit is contained in:
parent
99b076df80
commit
7809ae1756
@ -41,14 +41,13 @@ constructAndRun construct comparable cost t1 t2
|
|||||||
| not $ comparable t1 t2 = Nothing
|
| not $ comparable t1 t2 = Nothing
|
||||||
| (category <$> t1) == (category <$> t2) = hylo construct runCofree <$> zipTerms t1 t2
|
| (category <$> t1) == (category <$> t2) = hylo construct runCofree <$> zipTerms t1 t2
|
||||||
| otherwise =
|
| otherwise =
|
||||||
run construct comparable cost $ algorithm a b where
|
run construct comparable cost $ algorithm (unwrap t1) (unwrap t2) where
|
||||||
algorithm (Indexed a') (Indexed b') = do
|
algorithm (Indexed a') (Indexed b') = do
|
||||||
diffs <- byIndex a' b'
|
diffs <- byIndex a' b'
|
||||||
annotate (Indexed diffs)
|
annotate (Indexed diffs)
|
||||||
algorithm (Leaf a') (Leaf b') | a' == b' = annotate $ Leaf b'
|
algorithm (Leaf a') (Leaf b') | a' == b' = annotate $ Leaf b'
|
||||||
algorithm _ _ = recursively t1 t2
|
algorithm _ _ = recursively t1 t2
|
||||||
(annotation1 :< a, annotation2 :< b) = (runCofree t1, runCofree t2)
|
annotate = pure . construct . (both (extract t1) (extract t2) :<)
|
||||||
annotate = pure . construct . (both annotation1 annotation2 :<)
|
|
||||||
|
|
||||||
algorithmWithTerms :: Eq leaf => Term leaf (Record fields) -> Term leaf (Record fields) -> Algorithm (Term leaf (Record fields)) (Diff leaf (Record fields)) (Diff leaf (Record fields))
|
algorithmWithTerms :: Eq leaf => Term leaf (Record fields) -> Term leaf (Record fields) -> Algorithm (Term leaf (Record fields)) (Diff leaf (Record fields)) (Diff leaf (Record fields))
|
||||||
algorithmWithTerms t1 t2 = case (unwrap t1, unwrap t2) of
|
algorithmWithTerms t1 t2 = case (unwrap t1, unwrap t2) of
|
||||||
|
Loading…
Reference in New Issue
Block a user