1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Extract the recur function into the where clause.

This commit is contained in:
Rob Rix 2016-08-04 10:33:37 -04:00
parent 5acf6ff0f2
commit d12dd5d567

View File

@ -57,8 +57,9 @@ algorithmWithTerms t1 t2 = case (unwrap t1, unwrap t2) of
-- | Runs the diff algorithm
run :: (Eq leaf, Hashable leaf, Eq (Record fields), HasField fields Category) => DiffConstructor leaf (Record fields) -> Comparable leaf (Record fields) -> SES.Cost (Diff leaf (Record fields)) -> Algorithm (Term leaf (Record fields)) (Diff leaf (Record fields)) (Diff leaf (Record fields)) -> Maybe (Diff leaf (Record fields))
run construct comparable cost = runAlgorithm construct (constructAndRun construct comparable cost) cost getLabel . fmap Just
where getLabel (h :< t) = (category h, case t of
run construct comparable cost = runAlgorithm construct recur cost getLabel . fmap Just
where recur = constructAndRun construct comparable cost
getLabel (h :< t) = (category h, case t of
Leaf s -> Just s
_ -> Nothing)