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

📝 decoratorWithAlgebra.

This commit is contained in:
Rob Rix 2017-04-24 15:35:47 -04:00
parent 5201cb3f46
commit 0a6555351b

View File

@ -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