Skip to main content
×
×
Home

A representation theorem for second-order functionals

  • MAURO JASKELIOFF (a1) and RUSSELL O'CONNOR (a2)
Abstract

Representation theorems relate seemingly complex objects to concrete, more tractable ones. In this paper, we take advantage of the abstraction power of category theory and provide a datatype-generic representation theorem. More precisely, we prove a representation theorem for a wide class of second-order functionals which are polymorphic over a class of functors. Types polymorphic over a class of functors are easily representable in languages such as Haskell, but are difficult to analyse and reason about. The concrete representation provided by the theorem is easier to analyse, but it might not be as convenient to implement. Therefore, depending on the task at hand, the change of representation may prove valuable in one direction or the other. We showcase the usefulness of the representation theorem with a range of examples. Concretely, we show how the representation theorem can be used to prove that traversable functors are finitary containers, how coalgebras of a parameterised store comonad relate to very well-behaved lenses, and how algebraic effects might be implemented in a functional language.

    • Send article to Kindle

      To send this article to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about sending to your Kindle. Find out more about sending to your Kindle.

      Note you can select to send to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be sent to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

      Find out more about the Kindle Personal Document Service.

      A representation theorem for second-order functionals
      Available formats
      ×
      Send article to Dropbox

      To send this article to your Dropbox account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your <service> account. Find out more about sending content to Dropbox.

      A representation theorem for second-order functionals
      Available formats
      ×
      Send article to Google Drive

      To send this article to your Google Drive account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your <service> account. Find out more about sending content to Google Drive.

      A representation theorem for second-order functionals
      Available formats
      ×
Copyright
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/3.0/), which permits unrestricted re-use, distribution, and reproduction in any medium, provided the original work is properly cited.
References
Hide All
Abbott, M., Altenkirch, T. & Ghani, N. (2003) Categories of containers. In Proceedings of Foundation s of Software Science and Computation Structures. pp. 2338.
Atkey, R. (2009a) Algebras for parameterised monads. In Proceedings of the Algebra and Coalgebra in Computer Science, 3rd International Conference, CALCO 2009, Udine, Italy (September 7–10, 2009), Kurz, A., Lenisa, M. & Tarlecki, A. (eds), vol. 5728. Lecture Notes in Computer Science, Springer, pp. 317.
Atkey, R. (2009b) Parameterised notions of computation. J. Funct. Program. 19 (3 & 4), 335376.
Awodey, S. (2006) Category Theory. USA: Oxford University Press.
Bainbridge, E. S., Freyd, P. J., Scedrov, A. & Scott, P. J. (1990) Functorial polymorphism. Theor. Comput. Sci. 70 (1), 3564.
Bauer, A., Hofmann, M. & Karbyshev, A. (2013) On monadic parametricity of second-order functionals. In Foundations of Software Science and Computation Structures, Pfenning, F. (ed), vol. 7794. Lecture Notes in Computer Science, . Berlin Heidelberg: Springer, pp. 225240.
Bernardy, J.-P., Jansson, P. & Claessen, K. (2010) Testing polymorphic properties. In Programming Languages and Systems, Gordon, A. D. (ed), vol. 6012. Lecture Notes in Computer Science. Berlin Heidelberg: Springer, pp. 125144.
Bird, R. & de Moor, O. (1997) Algebra of Programming. Upper Saddle River, NJ, USA: Prentice-Hall.
Bird, R., Gibbons, J., Mehner, S., Voigtländer, J. & Schrijvers, T. (2013) Understanding idiomatic traversals backwards and forwards. In Proceedings of the 2013 ACM SIGPLAN Symposium on Haskell. Haskell '13. New York, NY, USA: ACM, pp. 2536.
Capriotti, P. & Kaposi, A. 2014 (April) Free applicative functors. In Proceedings of the 5th Workshop on Mathematically Structured Functional Programming. MSFP '14, pp. 230.
Danielsson, N. A., Hughes, J., Jansson, P. & Gibbons, J. (2006) Fast and loose reasoning is morally correct. Sigplan Not. 41 (1), 206217.
Foster, J. N., Greenwald, M. B., Moore, J. T., Pierce, B. C. & Schmitt, A. (2007) Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Trans. Program. Lang. Syst. 29 (3). (Article 17).
Gibbons, J. & Johnson, M. (2012) Relating algebraic and coalgebraic descriptions of lenses. 49 (Bidirectional Transformations 2012). Berlin, Germany.
Gibbons, J. & Oliveira, B. C. D. S. (2009) The essence of the iterator pattern. J. Funct. Program., 19, 377402.
Jaskelioff, M. & Rypacek, O. (2012) An investigation of the laws of traversals. In Proceedings of the 4th Workshop on Mathematically Structured Functional Programming. EPTCS, Chapman, J. & Levy, P. B. (eds), vol. 76, pp. 4049.
Kmett, E. 2013 (October) Lens-4.0: Lenses, Folds and Traversals. Available at: http://ekmett.github.io/lens/Control-Lens-Traversal.html.
Mac Lane, S. (1971) Categories for the Working Mathematician. Graduate Texts in Mathematics, no. 5, 2nd ed., Springer-Verlag, 1998.
McBride, C. & Paterson, R. (2008) Applicative programming with effects. J. Funct. Program. 18 (01), 113.
Milewski, B. 2013 (October) Lenses, Stores, and Yoneda. Available at: http://bartoszmilewski.com/2013/10/08/lenses-stores-and-yoneda.
Moggi, E., Bellè, G. & Jay, C. B. (1999) Monads, shapely functors and traversals. Electron. Notes Theor. Comput. Sci. 29, 187208.
O'Connor, R. 2010 (Nov.) Lenses are Exactly the Coalgebras for the Store Comonad. Available at: http://r6research.livejournal.com/23705.html.
O'Connor, R. (2011) Functor is to lens as applicative is to biplate: Introducing multiplate. Corr, abs/1103.2841v1.
O'Connor, R., Kmett, E. A. & Morris, T. 2013 (October) Data-lens-2.10.4: Haskell 98 lenses. Available at: http://hackage.haskell.org/package/data-lens-2.10.4/docs/Data-Lens-Partial-Common.html.
Plotkin, G. & Power, J. (2003) Algebraic operations and generic effects. Appl. Categ. Struct. 11 (1), 6994.
Plotkin, G. & Pretnar, M. (2009) Handlers of algebraic effects. In Programming Languages and Systems, Castagna, G. (ed), vol. 5502. Lecture Notes in Computer Science, . Berlin Heidelberg: Springer.
Reynolds, J. C. & Plotkin, G. D. (1993) On functors expressible in the polymorphic typed lambda calculus. Inform. Comput. 105 (1), 129.
Swierstra, W. (2008) Data types à la carte. J. Funct. Program. 18 (4), 423436.
Van Laarhoven, T. 2009a (Aug.) CPS Based Functional References. Available at: http://twanvl.nl/blog/haskell/cps-functional-references.
Van Laarhoven, T. 2009b (Apr.) A Non-Regular Data Type Challenge. Available at: http://twanvl.nl/blog/haskell/non-regular1.
Van Laarhoven, T. 2009c (Apr.) Where Do I Get My Non-Regular Types? Available at: http://twanvl.nl/blog/haskell/non-regular2.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 408 *
Loading metrics...

Abstract views

Total abstract views: 373 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 18th September 2018. This data will be updated every 24 hours.

A representation theorem for second-order functionals

  • MAURO JASKELIOFF (a1) and RUSSELL O'CONNOR (a2)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *