Skip to main content

The essence of ornaments


Functional programmers from all horizons strive to use, and sometimes abuse, their favorite type system in order to capture the invariants of their programs. A widely used tool in that trade consists in defining finely indexed datatypes. Operationally, these types classify the programmer's data, following the ML tradition. Logically, these types enforce the program invariants in a novel manner. This new programming pattern, by which one programs over inductive definitions to account for some invariants, lead to the development of a theory of ornaments (McBride, 2011 Ornamental Algebras, Algebraic Ornaments. Unpublished). However, ornaments originate as a dependently-typed object and may thus appear rather daunting to a functional programmer of the non-dependent kind. This article aims at presenting ornaments from first-principles and, in particular, to declutter their presentation from syntactic considerations. To do so, we shall give a sufficiently abstract model of indexed datatypes by means of many-sorted signatures. In this process, we formalize our intuition that an indexed datatype is the combination of a data-structure and a data-logic. Over this abstraction of datatypes, we shall recast the definition of ornaments, effectively giving a model of ornaments. Benefiting both from the operational and abstract nature of many-sorted signatures, ornaments should appear applicable and, one hopes, of interest beyond the type-theoretic circles, case in point being languages with generalized abstract datatypes or refinement types.

Hide All
Abbott, M. (2003) Categories of Containers. Ph.D. thesis, University of Leicester.
Abbott, M., Altenkirch, T., McBride, C. & Ghani, N. (2005) ∂ for data: Differentiating data structures. Fundam. Inform. 65 (1–2), 128.
Adelson-Velskii, G. & Landis, E. (1962) An algorithm for the organization of information. Dokl. Akad. Nauk USSR 146 (2), 263266.
Atkey, R., Johann, P. & Ghani, N. (2012) Refining inductive types. Log. Methods Comput. Sci. 8 (2), 130.
Brady, E. (2013) Idris, a general-purpose dependently typed programming language: Design and implementation. J. Funct. Program. 23 (5), 552593.
Cheney, J. & Hinze, R. (2003) First-Class Phantom Types. Technical Report, Cornell University.
Chlipala, A. (2013) Certified Programming with Dependent Types. MIT Press.
Constable, R. L. (1986) Implementing Mathematics with the Nuprl Proof Development System. Prentice Hall.
Coq development team. (2015) The Coq proof assistant reference manual.
Dagand, P.-E. & McBride, C. (2012) Transporting functions across ornaments. In Proceedings of International Conference on Functional Programming, Copenhagen, Denmark: ACM, pp. 103114.
Dagand, P.-E. & McBride, C. (2013) A categorical treatment of ornaments. Logics Comput. Sci. 530–539.
Dybjer, P. (1994) Inductive families. Form. Asp. Comput. 6 (4), 440465.
Dybjer, P. (1997) Representing inductively defined sets by wellorderings in Martin-Löf's type theory. Theor. Comput. Sci. 176 (1–2), 329335.
Freeman, T. & Pfenning, F. (1991) Refinement types for ML. In Programming Language Design and Implementation, Toronto, Ontario, Canada: ACM, pp. 268277.
Fumex, C. (2012) Induction and Coinduction Schemes in Category Theory. PhD Thesis, University of Strathclyde.
Gambino, N. & Hyland, M. (2004) Wellfounded trees and dependent polynomial functors. In Types for Proofs and Programs, vol. 3085, Springer Berlin Heidelberg, Berlin, Heidelberg, pp. 210225.
Gambino, N. & Kock, J. (2013) Polynomial functors and polynomial monads. Math. Proc. Camb. Phil. Soc. 154 (1), 153192.
Goguen, H. & Luo, Z. (1993) Inductive data types: Well-ordering types revisited. In Workshop on Logical Environments, Cambridge University Press, pp. 198218.
Goguen, J. A., Thatcher, J. W., Wagner, E. G. & Wright, J. B. (1975 May) Abstract data-types as initial algebras and correctness of data representations. In Proceedings of the Conference on Computer Graphics, Pattern Recognition and Data Structure.
Guibas, L. J. & Sedgewick, R. (1978) A dichromatic framework for balanced trees. In Foundations of Computer Science, pp. 8–21.
Hamana, M. & Fiore, M. (2011) A foundation for GADTs and inductive families: Dependent polynomial functor approach. In Workshop on Generic Programming, pp. 59–70.
Hinze, R. (1998) Numerical Representations as Higher-Order Nested Datatypes. Technical Report, Institut für Informatik III, Universität Bonn.
Huet, G. (1997) The zipper. J. Funct. Program. 7 (05), 549554.
Knuth, D. E. (1981) The Art of Computer Programming, Volume II: Seminumerical Algorithms. Addison-Wesley.
Ko, H.-S. (2014) Analysis and Synthesis of Inductive Families. PhD Thesis, University of Oxford.
Ko, H.-S. & Gibbons, J. (2011) Modularising inductive families. In Workshop on Generic Programming, pp. 13–24.
Ko, H.-S. & Gibbons, J. (2013) Relational algebraic ornaments. In Workshop on Dependently-Typed Programming, pp. 37–48.
Martin-Löf, P. (1984) Intuitionistic Type Theory. Bibliopolis Napoli.
McBride, C. (2011) Ornamental Algebras, Algebraic Ornaments. Unpublished.
Morris, P. (2007) Constructing Universes for Generic Programming. PhD Thesis, University of Nottingham.
Morris, P. & Altenkirch, T. (2009) Indexed containers. Logics Comput. Sci. pp. 277–285.
Morris, P., Altenkirch, T. & Ghani, N. (2009) A universe of strictly positive families. Int. J. Found. Comput. Sci. 20 (1), 83107.
Norell, U. (2007) Towards a Practical Programming Language Based on Dependent Type Theory. PhD Thesis, Chalmers University of Technology.
Okasaki, C. (1998) Purely Functional Data Structures. Cambridge University Press.
Petersson, K. & Synek, D. (1989) A set constructor for inductive sets in Martin-Löf's type theory. In Category Theory and Computer Science, pp. 128–140.
Pottier, F. & Régis-Gianas, Y. (2006) Stratified type inference for generalized algebraic data types. In Principles of Programming Languages, Charleston, South Carolina, USA: ACM, pp. 232244.
Schrijvers, T., Peyton Jones, S., Sulzmann, M. & Vytiniotis, D. (2009) Complete and decidable type inference for GADTs. In Proceedings of International Conference on Functional Programming, Edinburgh, Scotland: ACM, pp. 341–352.
Seely, R. A. G. (1983) Locally cartesian closed categories and type theory. Math. Proc. Camb. Phil. Soc. 95 (1), 3348.
Sheard, T. & Linger, N. (2007) Programming in Omega. In Central European Functional Programming School. vol. 5161, Lecture Notes in Computer Science, Springer, pp. 158227.
Smyth, M. B. & Plotkin, G. D. (1982) The category-theoretic solution of recursive domain equations. In Foundations of Computer Science 11 (4), pp. 761783.
Swamy, N., Chen, J., Fournet, C., Strub, P.-Y., Bhargavan, K. & Yang, J. (2011) Secure distributed programming with value-dependent types. In Proceedings of International Conference on Functional Programming, ACM, pp. 266–278.
Williams, T., Dagand, P.-É. & Rémy, D. (2014) Ornaments in practice. In Workshop on Generic Programming, Gothenburg, Sweden: ACM, pp. 1524.
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? *


Altmetric attention score

Full text views

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

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

The essence of ornaments

Submit a response


No Discussions have been published for this article.


Reply to: Submit a response

Your details

Conflicting interests

Do you have any conflicting interests? *