Difference between revisions of "Zygohistomorphic prepromorphisms"

From HaskellWiki
Jump to: navigation, search
m
Line 1: Line 1:
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.
+
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 ala a paramorphism.
   
 
<pre>
 
<pre>
Line 8: Line 8:
   
 
zygohistomorphic_prepromorphism :: Algebra f b -> GAlgebra f (Cofree f) a -> (f :~> f) -> FixF f -> a
 
zygohistomorphic_prepromorphism :: 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.
+
zygohistomorphic_prepromorphism f = g_prepro (distZygoT (liftAlgebra f) (distHisto id))
  +
-- unless you want a generalized zygomorphism.
 
</pre>
 
</pre>

Revision as of 01:39, 9 June 2008

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 ala a paramorphism.

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

zygohistomorphic_prepromorphism :: 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.