Abstract
Adjunctions are among the most important constructions in mathematics. These lecture notes show they are also highly relevant to datatype-generic programming. First, every fundamental datatype—sums, products, function types, recursive types—arises out of an adjunction. The defining properties of an adjunction give rise to well-known laws of the algebra of programming. Second, adjunctions are instrumental in unifying and generalising recursion schemes. We discuss a multitude of basic adjunctions and show that they are directly relevant to programming and to reasoning about programs.
Keywords
- Natural Transformation
- Category Theory
- Universal Property
- Recursive Call
- Left Adjoint
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
This is a preview of subscription content, access via your institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Jones, M.P.: A system of constructor classes: overloading and implicit higher-order polymorphism. Journal of Functional Programming 5(1), 1–35 (1995)
Wadler, P.: Theorems for free! In: The Fourth International Conference on Functional Programming Languages and Computer Architecture (FPCA 1989), pp. 347–359. Addison-Wesley Publishing Company, London (1989)
Wadler, P.: Comprehending monads. In: Proceedings of the 1990 ACM Conference on LISP and Functional Programming, pp. 61–78. ACM Press, Nice (1990)
McBride, C., Paterson, R.: Functional Pearl: Applicative programming with effects. Journal of Functional Programming 18(1), 1–13 (2008)
Meijer, E., Fokkinga, M., Paterson, R.: Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 124–144. Springer, Heidelberg (1991)
Gibbons, J., Jones, G.: The under-appreciated unfold. In: Felleisen, M., Hudak, P., Queinnec, C. (eds.) Proceedings of the Third ACM SIGPLAN International Conference on Functional Programming, pp. 273–279. ACM Press (1998)
Kan, D.M.: Adjoint functors. Transactions of the American Mathematical Society 87(2), 294–329 (1958)
Mac Lane, S.: Categories for the Working Mathematician, 2nd edn. Graduate Texts in Mathematics. Springer, Berlin (1998)
Bird, R., De Moor, O.: Algebra of Programming. Prentice Hall Europe, London (1997)
Hinze, R.: A category theory primer (2010), http://www.cs.ox.ac.uk/ralf.hinze/SSGIP10/Notes.pdf
Hinze, R.: Adjoint folds and unfolds—an extended study. Science of Computer Programming (2011) (to appear)
Mulry, P.: Strong monads, algebras and fixed points. In: Fourman, M., Johnstone, P., Pitts, A. (eds.) Applications of Categories in Computer Science. Cambridge University Press (1992)
Lambek, J.: A fixpoint theorem for complete categories. Math. Zeitschr. 103, 151–161 (1968)
Hinze, R., James, D.W.H.: Reason isomorphically? In: Oliveira, B.C., Zalewski, M. (eds.) Proceedings of the 6th ACM SIGPLAN Workshop on Generic Programming (WGP 2010), pp. 85–96. ACM, New York (2010)
Peyton Jones, S.: Haskell 98 Language and Libraries. Cambridge University Press (2003)
Cockett, R., Fukushima, T.: About Charity. Yellow Series Report 92/480/18, Dept. of Computer Science, Univ. of Calgary (June 1992)
The Coq Development Team: The Coq proof assistant reference manual (2010), http://coq.inria.fr
Goguen, J.A., Thatcher, J.W., Wagner, E.G., Wright, J.B.: Initial algebra semantics and continuous algebras. Journal of the ACM 24(1), 68–95 (1977)
Smyth, M.B., Plotkin, G.D.: The category-theoretic solution of recursive domain equations. SIAM Journal on Computing 11(4), 761–783 (1982)
Sheard, T., Pasalic, T.: Two-level types and parameterized modules. Journal of Functional Programming 14(5), 547–587 (2004)
Mendler, N.P.: Inductive types and type constraints in the second-order lambda calculus. Annals of Pure and Applied Logic 51(1-2), 159–172 (1991)
Giménez, E.: Codifying Guarded Definitions with Recursive Schemes. In: Smith, J., Dybjer, P., Nordström, B. (eds.) TYPES 1994. LNCS, vol. 996, pp. 39–59. Springer, Heidelberg (1995)
Okasaki, C.: Purely Functional Data Structures. Cambridge University Press (1998)
Bird, R.S., Meertens, L.: Nested Datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)
Mycroft, A.: Polymorphic Type Schemes and Recursive Definitions. In: Paul, M., Robinet, B. (eds.) Programming 1984. LNCS, vol. 167, pp. 217–228. Springer, Heidelberg (1984)
Hinze, R., Peyton Jones, S.: Derivable type classes. In: Hutton, G. (ed.) Proceedings of the 2000 ACM SIGPLAN Haskell Workshop. Electronic Notes in Theoretical Computer Science, vol. 41(1), pp. 5–35. Elsevier Science (2001); The preliminary proceedings appeared as a University of Nottingham technical report
Trifonov, V.: Simulating quantified class constraints. In: Haskell 2003: Proceedings of the 2003 ACM SIGPLAN Workshop on Haskell, pp. 98–102. ACM, New York (2003)
Lämmel, R., Peyton Jones, S.: Scrap your boilerplate with class: extensible generic functions. In: Pierce, B. (ed.) Proceedings of the 2005 International Conference on Functional Programming, Tallinn, Estonia, September 26–28 (2005)
Meertens, L.: Paramorphisms. Formal Aspects of Computing 4, 413–424 (1992)
Backhouse, R., Bijsterveld, M., Van Geldrop, R., Van der Woude, J.: Category theory as coherently constructive lattice theory (2003), Working Document, available from, http://www.cs.nott.ac.uk/~rcb/MPC/CatTheory.ps.gz
Bird, R., Paterson, R.: Generalised folds for nested datatypes. Formal Aspects of Computing 11(2), 200–222 (1999)
Hinze, R.: Efficient generalized folds. In: Jeuring, J. (ed.) Proceedings of the Second Workshop on Generic Programming, pp. 1–16 (2000); The Proceedings appeared as a technical report of Universiteit Utrecht, UU-CS-2000-19
Hinze, R.: Kan Extensions for Program Optimisation Or: Art and Dan Explain an Old Trick. In: Gibbons, J., Nogueira, P. (eds.) MPC 2012. LNCS, vol. 7342, pp. 324–362. Springer, Heidelberg (2012)
Eilenberg, S., MacLane, S.: General theory of natural equivalences. Transactions of the American Mathematical Society 58(2), 231–294 (1945)
Awodey, S.: Category Theory, 2nd edn. Oxford University Press (2010)
Barr, M., Wells, C.: Category Theory for Computing Science, 3rd edn. Les Publications CRM, Montréal (1999), The book is available from Centre de recherches mathématiques, http://crm.umontreal.ca/
Pierce, B.C.: Basic Category Theory for Computer Scientists. The MIT Press (1991)
Rydeheard, D.: Adjunctions. In: Poigné, A., Pitt, D.H., Rydeheard, D.E., Abramsky, S. (eds.) Category Theory and Computer Programming. LNCS, vol. 240, pp. 51–57. Springer, Heidelberg (1986)
Spivey, M.: A Categorical Approach to the Theory of Lists. In: van de Snepscheut, J.L.A. (ed.) MPC 1989. LNCS, vol. 375, pp. 399–408. Springer, Heidelberg (1989)
Bird, R.: An introduction to the theory of lists. In: Broy, M. (ed.) Proceedings of the NATO Advanced Study Institute on Logic of Programming and Calculi of Discrete Design, Marktoberdorf, Germany, pp. 5–42. Springer, Heidelberg (1987)
Bird, R.: A calculus of functions for program derivation. Technical Report PRG-64, Programming Research Group, Oxford University Computing Laboratory (1987)
Fokkinga, M.M., Meertens, L.: Adjunctions. Technical Report Memoranda Inf. 94-31, University of Twente, Enschede, Netherlands (June 1994)
Malcolm, G.: Data structures and program transformation. Science of Computer Programming 14(2-3), 255–280 (1990)
Fokkinga, M.M.: Law and Order in Algorithmics. PhD thesis, University of Twente (February 1992)
Pardo, A.: Generic accumulations. In: Gibbons, J., Jeuring, J. (eds.) Proceedings of the IFIP TC2 Working Conference on Generic Programming, Schloss Dagstuhl, pp. 49–78. Kluwer Academic Publishers (July 2002)
Hagino, T.: A Typed Lambda Calculus with Categorical Type Constructors. In: Pitt, D.H., Rydeheard, D.E., Poigné, A. (eds.) Category Theory and Computer Science. LNCS, vol. 283, pp. 140–157. Springer, Heidelberg (1987)
Connelly, R.H., Morris, F.L.: A generalization of the trie data structure. Mathematical Structures in Computer Science 5(3), 381–418 (1995)
Okasaki, C.: Catenable double-ended queues. In: Proceedings of the 1997 ACM SIGPLAN International Conference on Functional Programming, Amsterdam, The Netherlands, pp. 66–74 (June 1997); ACM SIGPLAN Notices 32(8) (August 1997)
De Bruin, P.J.: Inductive types in constructive languages. PhD thesis, University of Groningen (1995)
Uustalu, T., Vene, V., Pardo, A.: Recursion schemes from comonads. Nordic J. of Computing 8, 366–390 (2001)
Bartels, F.: Generalised coinduction. Math. Struct. Comp. Science 13, 321–348 (2003)
Capretta, V., Uustalu, T., Vene, V.: Recursive coalgebras from comonads. Information and Computation 204(4), 437–468 (2006)
Backhouse, R., Bijsterveld, M., Van Geldrop, R., Van der Woude, J.: Categorical Fixed Point Calculus. In: Johnstone, P.T., Rydeheard, D.E., Pitt, D.H. (eds.) CTCS 1995. LNCS, vol. 953, pp. 159–179. Springer, Heidelberg (1995)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Hinze, R. (2012). Generic Programming with Adjunctions. In: Gibbons, J. (eds) Generic and Indexed Programming. Lecture Notes in Computer Science, vol 7470. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-32202-0_2
Download citation
DOI: https://doi.org/10.1007/978-3-642-32202-0_2
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-32201-3
Online ISBN: 978-3-642-32202-0
eBook Packages: Computer ScienceComputer Science (R0)
