Difference between revisions of "Zygohistomorphic prepromorphisms"
Jump to navigation
Jump to search
(7 intermediate revisions by 3 users not shown) | |||
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 à la paramorphism. |
+ | |||
+ | <pre> |
||
+ | import Control.Morphism.Zygo |
||
+ | import Control.Morphism.Prepro |
||
+ | import Control.Morphism.Histo |
||
+ | import Control.Functor.Algebra |
||
+ | import Control.Functor.Extras |
||
+ | |||
+ | zygoHistoPrepro |
||
+ | :: (Unfoldable t, Foldable t) |
||
+ | => (Base t b -> b) |
||
+ | -> (forall c. Base t c -> Base t c) |
||
+ | -> (Base t (EnvT b (Stream (Base t)) a) -> a) |
||
+ | -> t |
||
+ | -> a |
||
+ | zygoHistoPrepro f g t = gprepro (distZygoT f distHisto) g t |
||
+ | -- unless you want a generalized zygomorphism. |
||
+ | </pre> |
Revision as of 21:03, 20 February 2011
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 zygoHistoPrepro :: (Unfoldable t, Foldable t) => (Base t b -> b) -> (forall c. Base t c -> Base t c) -> (Base t (EnvT b (Stream (Base t)) a) -> a) -> t -> a zygoHistoPrepro f g t = gprepro (distZygoT f distHisto) g t -- unless you want a generalized zygomorphism.