1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

cata over Fix.

This commit is contained in:
Rob Rix 2016-03-18 11:59:54 -04:00
parent 793025e65f
commit ea6fd75131

View File

@ -108,5 +108,8 @@ type Row a = Both (Line a)
-- | A fixpoint over a functor.
newtype Fix f = Fix { unFix :: f (Fix f) }
cata :: Functor f => (f a -> a) -> Fix f -> a
cata f = f . fmap (Alignment.cata f) . unFix
ana :: Functor f => (a -> f a) -> a -> Fix f
ana f = Fix . fmap (ana f) . f