Zygohistomorphic prepromorphisms

From HaskellWiki
Revision as of 12:30, 4 December 2010 by Xarch (talk | contribs) (Error in the use of « à la » (« la » is more or less the French for « the »))

Jump to: navigation, search

Used when you really need both semi-mutual recursion and history and to repeatedly apply a natural transformation as you get deeper into the functor. Zygo implements semi-mutual recursion like a zygomorphism. Para gives you access to your result à la paramorphism.

import Control.Morphism.Zygo
import Control.Morphism.Prepro
import Control.Morphism.Histo
import Control.Functor.Algebra
import Control.Functor.Extras

zygohistomorphic_prepromorphism :: Functor f => Algebra f b -> GAlgebra f (Cofree f) a -> (f :~> f) -> FixF f -> a
zygohistomorphic_prepromorphism f = g_prepro (distZygoT (liftAlgebra f) (distHisto id))
-- unless you want a generalized zygomorphism.