mirror of
https://github.com/github/semantic.git
synced 2025-01-03 21:16:12 +03:00
Rearrange the definition of constructAndRun a little.
This commit is contained in:
parent
7809ae1756
commit
0953d430b9
@ -38,11 +38,10 @@ diffComparableTerms construct comparable cost a b
|
|||||||
-- | Constructs an algorithm and runs it
|
-- | Constructs an algorithm and runs it
|
||||||
constructAndRun :: (Eq leaf, Hashable leaf, Eq (Record fields), HasField fields Category) => DiffConstructor leaf (Record fields) -> Comparable leaf (Record fields) -> SES.Cost (Diff leaf (Record fields)) -> Term leaf (Record fields) -> Term leaf (Record fields) -> Maybe (Diff leaf (Record fields))
|
constructAndRun :: (Eq leaf, Hashable leaf, Eq (Record fields), HasField fields Category) => DiffConstructor leaf (Record fields) -> Comparable leaf (Record fields) -> SES.Cost (Diff leaf (Record fields)) -> Term leaf (Record fields) -> Term leaf (Record fields) -> Maybe (Diff leaf (Record fields))
|
||||||
constructAndRun construct comparable cost t1 t2
|
constructAndRun construct comparable cost t1 t2
|
||||||
| 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 =
|
| comparable t1 t2 = run construct comparable cost $ algorithm (unwrap t1) (unwrap t2)
|
||||||
run construct comparable cost $ algorithm (unwrap t1) (unwrap t2) where
|
| otherwise = Nothing
|
||||||
algorithm (Indexed a') (Indexed b') = do
|
where 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'
|
||||||
|
Loading…
Reference in New Issue
Block a user