From 2b703d1f3132e7365573f4a91bbdb034b237421c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 25 Apr 2017 12:09:10 -0400 Subject: [PATCH] Generalize decoratorWithAlgebra to take an R-algebra. --- src/Language/Ruby/Syntax.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index abf81fb94..e64550475 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -153,7 +153,7 @@ cyclomaticComplexityAlg (_ :< union) = case union of -- | Lift an algebra into a decorator for terms annotated with records. decoratorWithAlgebra :: Functor f - => FAlgebra (Base (Term f (Record fs))) a -- ^ An F-algebra on terms. + => RAlgebra (Base (Term f (Record fs))) (Term f (Record fs)) a -- ^ An F-algebra on terms. -> Term f (Record fs) -- ^ A term to decorate with values produced by the F-algebra. -> Term f (Record (a ': fs)) -- ^ A term decorated with values produced by the F-algebra. -decoratorWithAlgebra alg = cata $ \ c@(a :< f) -> cofree $ (alg (fmap (rhead . extract) c) :. a) :< f +decoratorWithAlgebra alg = para $ \ c@(a :< f) -> cofree $ (alg (fmap (second (rhead . extract)) c) :. a) :< fmap snd f