From 0a6555351bce2c572b13b97b2fae35412d8c77c9 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 24 Apr 2017 15:35:47 -0400 Subject: [PATCH] :memo: decoratorWithAlgebra. --- src/Language/Ruby/Syntax.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index 1aa6c733c..3ae73cadf 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -130,5 +130,6 @@ cyclomaticComplexity = cata $ \ (_ :< union) -> case union of -- | An F-algebra on some carrier functor 'f'. type FAlgebra f a = f a -> a +-- | Lift an algebra into a decorator for terms annotated with records. decoratorWithAlgebra :: Functor f => FAlgebra (Base (Term f (Record fs))) a -> Term f (Record fs) -> Term f (Record (a ': fs)) decoratorWithAlgebra alg = cata $ \ c@(a :< f) -> cofree $ (alg (fmap (rhead . extract) c) :. a) :< f