mirror of
https://github.com/github/semantic.git
synced 2025-01-03 21:16:12 +03:00
Define recur by closing over the higher-order functions.
This commit is contained in:
parent
d9a1bd29f2
commit
e41a0589d5
@ -30,11 +30,11 @@ diffTerms :: (Eq leaf, Hashable leaf, Eq (Record fields), HasField fields Catego
|
|||||||
diffTerms construct comparable cost a b = fromMaybe (replacing a b) $ diffComparableTerms construct comparable cost a b
|
diffTerms construct comparable cost a b = fromMaybe (replacing a b) $ diffComparableTerms construct comparable cost a b
|
||||||
|
|
||||||
diffComparableTerms :: (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))
|
diffComparableTerms :: (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))
|
||||||
diffComparableTerms construct comparable cost a b
|
diffComparableTerms construct comparable cost = recur
|
||||||
|
where recur a b
|
||||||
| (category <$> a) == (category <$> b) = hylo construct runCofree <$> zipTerms a b
|
| (category <$> a) == (category <$> b) = hylo construct runCofree <$> zipTerms a b
|
||||||
| comparable a b = runAlgorithm construct recur cost getLabel (Just <$> algorithmWithTerms construct a b)
|
| comparable a b = runAlgorithm construct recur cost getLabel (Just <$> algorithmWithTerms construct a b)
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
where recur a b = diffComparableTerms construct comparable cost a b
|
|
||||||
getLabel (h :< t) = (category h, case t of
|
getLabel (h :< t) = (category h, case t of
|
||||||
Leaf s -> Just s
|
Leaf s -> Just s
|
||||||
_ -> Nothing)
|
_ -> Nothing)
|
||||||
|
Loading…
Reference in New Issue
Block a user