From e41a0589d56703e371e10b7ede910a42ca4b2776 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 4 Aug 2016 11:12:52 -0400 Subject: [PATCH] Define recur by closing over the higher-order functions. --- src/Interpreter.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Interpreter.hs b/src/Interpreter.hs index af5179c0d..67baa7dfd 100644 --- a/src/Interpreter.hs +++ b/src/Interpreter.hs @@ -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 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 - | (category <$> a) == (category <$> b) = hylo construct runCofree <$> zipTerms a b - | comparable a b = runAlgorithm construct recur cost getLabel (Just <$> algorithmWithTerms construct a b) - | otherwise = Nothing - where recur a b = 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 + | comparable a b = runAlgorithm construct recur cost getLabel (Just <$> algorithmWithTerms construct a b) + | otherwise = Nothing getLabel (h :< t) = (category h, case t of Leaf s -> Just s _ -> Nothing)