A representation theorem for second-order functionals

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 general 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 show that traversable functors are finitary containers, how parameterised coalgebras relate to very well-behaved lenses, and how algebraic effects might be implemented in a functional language.

[1]  Mauro Jaskelioff,et al.  An Investigation of the Laws of Traversals , 2012, MSFP.

[2]  Russell O'Connor Functor is to Lens as Applicative is to Biplate: Introducing Multiplate , 2011, ArXiv.

[3]  Tom Schrijvers,et al.  Understanding idiomatic traversals backwards and forwards , 2013, Haskell '13.

[4]  GibbonsJeremy,et al.  The essence of the iterator pattern , 2009 .

[5]  Nils Anders Danielsson,et al.  Fast and loose reasoning is morally correct , 2006, POPL '06.

[6]  Robert Atkey Algebras for Parameterised Monads , 2009, CALCO.

[7]  Wouter Swierstra,et al.  Data types à la carte , 2008, Journal of Functional Programming.

[8]  C. Barry Jay,et al.  Monads, shapely functors, and traversals , 1999, CTCS.

[9]  Benjamin C. Pierce,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[10]  Steve Awodey,et al.  Category Theory , 2006 .

[11]  Robert Atkey,et al.  Parameterised notions of computation , 2006, J. Funct. Program..

[12]  John C. Reynolds,et al.  On Functors Expressible in the Polymorphic Typed Lambda Calculus , 1993, Inf. Comput..

[13]  Thorsten Altenkirch,et al.  Foundations of Software Science and Computation Structures: 6th International Conference, FOSSACS 2003 Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2003 Warsaw, Poland, April 7–11, 2003 Proceedings , 2003, Lecture Notes in Computer Science.

[14]  Michael Johnson,et al.  Relating Algebraic and Coalgebraic Descriptions of Lenses , 2012, Electron. Commun. Eur. Assoc. Softw. Sci. Technol..

[15]  Koen Claessen,et al.  Testing Polymorphic Properties , 2010, ESOP.

[16]  Bruno C. d. S. Oliveira,et al.  The essence of the Iterator pattern , 2006, J. Funct. Program..

[17]  Richard S. Bird,et al.  Algebra of programming , 1997, Prentice Hall International series in computer science.

[18]  Aleksandr Karbyshev,et al.  Monadic Parametricity of Second-Order Functionals , 2013, FoSSaCS.

[19]  John Whitfield,et al.  Fast and loose , 2000 .

[20]  Andre Scedrov,et al.  Functorial Polymorphism , 1990, Theor. Comput. Sci..

[21]  Ambrus Kaposi,et al.  Free Applicative Functors , 2014, MSFP.

[22]  Conor McBride,et al.  Applicative programming with effects , 2008, J. Funct. Program..

[23]  Gordon D. Plotkin,et al.  Algebraic Operations and Generic Effects , 2003, Appl. Categorical Struct..

[24]  Gordon D. Plotkin,et al.  Handlers of Algebraic Effects , 2009, ESOP.