Abstract
The past decades have witnessed an extensive study of structured recursion schemes. A general scheme is the hylomorphism, which captures the essence of divide-and-conquer: a problem is broken into sub-problems by a coalgebra; sub-problems are solved recursively; the sub-solutions are combined by an algebra to form a solution. In this paper we develop a simple toolbox for assembling recursive coalgebras, which by definition ensure that their hylo equations have unique solutions, whatever the algebra. Our main tool is the conjugate rule, a generic rule parametrized by an adjunction and a conjugate pair of natural transformations. We show that many basic adjunctions induce useful recursion schemes. In fact, almost every structured recursion scheme seems to arise as an instance of the conjugate rule. Further, we adapt our toolbox to the more expressive setting of parametrically recursive coalgebras, where the original input is also passed to the algebra. The formal development is complemented by a series of worked-out examples in Haskell.
Supplemental Material
- J. Adámek, D. Lücke, and S. Milius, "Recursive coalgebras of finitary functors," RAIRO-Theoretical Informatics and Applications, vol. 41, no. 04, pp. 447--462, 2007.Google Scholar
Cross Ref
- R. Backhouse and H. Doornbos, "Datatype-generic termination proofs," English Theory of Comput. Sys., vol. 43, no. 3--4, pp. 362--393, 2008. Google Scholar
Digital Library
- R. Backhouse, M. Bijsterveld, R. van Geldrop, and J. van der Woude, "Categorical fixed point calculus," in Category Theory and Computer Science, ser. LNCS, vol. 953. Springer, Aug. 1995, pp. 159--179. Google Scholar
Digital Library
- R. Bird and O. de Moor, Algebra of Programming. Prentice Hall Europe, 1997. Google Scholar
Digital Library
- R. Bird and R. Paterson, "Generalised folds for nested datatypes," Form. Asp. Comput., vol. 11, no. 2, pp. 200--222, 1999.Google Scholar
Cross Ref
- V. Capretta, T. Uustalu, and V. Vene, "Recursive coalgebras from comonads," Inform. Comput., vol. 204, no. 4, pp. 437--468, 2006. Google Scholar
Digital Library
- A. Eppendahl, "Coalgebra-to-algebra morphisms," Electronic Notes in Theoretical Computer Science, vol. 29, no. 0, pp. 42--49, 1999.Google Scholar
Cross Ref
- M. M. Fokkinga, "Tupling and mutumorphisms," The Squiggolist, vol. 1, no. 4, pp. 81--82, Jun. 1990.Google Scholar
- P. Freyd, "Algebraically complete categories," in Category Theory, ser. Lect. Notes Math. Springer, 1991, vol. 1488, pp. 95--104.Google Scholar
- T. Hagino, "Category theoretic approach to data types," Ph.D. dissertation, University of Edinburgh, 1987.Google Scholar
- R. Hinze, "Adjoint folds and unfolds--an extended study," Sci. Comput. Program., vol. 78, no. 11, pp. 2108--2159, 2013. Google Scholar
Digital Library
- R. Hinze and N. Wu, "Histo- and dynamorphisms revisited," in Workshop on Generic Program. ACM, 2013, pp. 1--12. Google Scholar
Digital Library
- R. Hinze, N. Wu, and J. Gibbons, "Unifying structured recursion schemes," in ICFP. ACM, 2013, pp. 209--220. Google Scholar
Digital Library
- C. A. R. Hoare, "Notes on data structuring," in Structured Programming, ser. APIC studies in data processing. Academic Press, 1972, pp. 83--174. Google Scholar
Digital Library
- Z. Hu, H. Iwasaki, and M. Takeichi, "Deriving structural hylomorphisms from recursive definitions," in ICFP. ACM, 1996, pp. 73--82. Google Scholar
Digital Library
- J. Kabanov and V. Vene, "Recursion schemes for dynamic programming," in Math. of Prog. Construction, ser. LNCS. Springer, 2006, pp. 235--252. Google Scholar
Digital Library
- D. M. Kan, "Adjoint functors," Trans. Am. Math. Soc., vol. 87, no. 2, pp. 294--329, 1958.Google Scholar
Cross Ref
- J. Lambek, "A fixpoint theorem for complete categories," Math. Z., vol. 103, pp. 151--161, 1968.Google Scholar
Cross Ref
- S. Mac Lane, Categories for the Working Mathematician, 2nd ed., ser. Graduate Texts in Mathematics. Springer, 1998.Google Scholar
- G. Malcolm, "Algebraic data types and program transformation," Ph.D. dissertation, University of Groningen, 1990.Google Scholar
- ----, "Data structures and program transformation," Sci. Comput. Program., vol. 14, no. 2--3, pp. 255--280, 1990. Google Scholar
Digital Library
- L. Meertens, "Paramorphisms," Form. Asp. Comput., vol. 4, pp. 413--424, 1992.Google Scholar
Cross Ref
- E. Meijer, M. Fokkinga, and R. Paterson, "Functional programming with bananas, lenses, envelopes and barbed wire," in Functional Programming Languages and Computer Architecture, ser. LNCS, vol. 523. Springer, 1991, pp. 124--144. Google Scholar
Digital Library
- S. Milius, "Completely iterative algebras and completely iterative monads," Inform. Comput., vol. 196, no. 1, pp. 1--41, 2005. Google Scholar
Digital Library
- G. Osius, "Categorical set theory: A characterization of the category of sets," J. Pure Appl. Algebra, vol. 4, no. 1, pp. 79--119, 1974.Google Scholar
Cross Ref
- A. Pardo, "Generic accumulations," in IFIP TC2 Working Conference on Generic Program., vol. 24 Kluwer Academic Publishers, Jul. 2002, pp. 49--78. Google Scholar
Digital Library
- P. Taylor, Practical Foundations of Mathematics, ser. Cambridge Studies in Adv. Math. Cambridge University Press, 1999, no. 59.Google Scholar
- T. Uustalu and V. Vene, "Coding recursion à la Mendler," in Workshop on Generic Program., Jul. 2000, pp. 69--85.Google Scholar
- ----, "Primitive (co)recursion and course-of-value (co)iteration, categorically," Informatica, Lith. Acad. Sci., vol. 10, no. 1, pp. 5--26, 1999.Google Scholar
- ----, "The recursion scheme from the cofree recursive comonad," Electronic Notes in Theoretical Computer Science, vol. 229, no. 5, pp. 135--157, 2011, Math. Structured Functional Program. 2008. Google Scholar
Digital Library
- T. Uustalu, V. Vene, and A. Pardo, "Recursion schemes from comonads," Nordic J. Comput., vol. 8, pp. 366--390, Sep. 2001. Google Scholar
Digital Library
- V. Vene and T. Uustalu, "Functional programming with apomorphisms (corecursion)," Proceedings of the Estonian Academy of Sciences: Physics, Mathematics, vol. 47, no. 3, pp. 147--161, 1998.Google Scholar
Cross Ref
Index Terms
Conjugate Hylomorphisms -- Or: The Mother of All Structured Recursion Schemes
Recommendations
Conjugate Hylomorphisms -- Or: The Mother of All Structured Recursion Schemes
POPL '15: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesThe past decades have witnessed an extensive study of structured recursion schemes. A general scheme is the hylomorphism, which captures the essence of divide-and-conquer: a problem is broken into sub-problems by a coalgebra; sub-problems are solved ...
Unifying structured recursion schemes
ICFP '13Folds over inductive datatypes are well understood and widely used. In their plain form, they are quite restricted; but many disparate generalisations have been proposed that enjoy similar calculational benefits. There have also been attempts to unify ...
Folding domain-specific languages: deep and shallow embeddings (functional Pearl)
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programmingA domain-specific language can be implemented by embedding within a general-purpose host language. This embedding may be deep or shallow, depending on whether terms in the language construct syntactic or semantic representations. The deep and shallow ...







Comments