Abstract
Ornaments are a way to describe changes in datatype definitions reorganizing, adding, or dropping some pieces of data so that functions operating on the bare definition can be partially and sometimes totally lifted into functions operating on the ornamented structure. We propose an extension of ML with higher-order ornaments, demonstrate its expressiveness with a few typical examples, including code refactoring, study the metatheoretical properties of ornaments, and describe their elaboration process. We formalize ornamentation via an a posteriori abstraction of the bare code, returning a generic term, which lives in a meta-language above ML. The lifted code is obtained by application of the generic term to well-chosen arguments, followed by staged reduction, and some remaining simplifications. We use logical relations to closely relate the lifted code to the bare code.
Supplemental Material
- Jean-Philippe Bernardy and Moulin Guilhem. 2013. Type-theory in color. In International Conference on Functional Programming. 61–72. Google Scholar
Digital Library
- Pierre Chambard and Grégoire Henry. 2012. Experiments in generic programming: runtime type representation and implicit values. Presentation at the OCaml Users and Developers meeting, Copenhagen, Denmark. (sep 2012). http: //oud.ocaml.org/2012/slides/oud2012- paper4- slides.pdfGoogle Scholar
- Pierre-Évariste Dagand and Conor McBride. 2013. A Categorical Treatment of Ornaments. In 28th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2013, New Orleans, LA, USA, June 25-28, 2013. IEEE Computer Society, 530–539. Google Scholar
Digital Library
- Pierre-Évariste Dagand and Conor McBride. 2014. Transporting functions across ornaments. J. Funct. Program. 24, 2-3 (2014), 316–383. Google Scholar
Cross Ref
- Dominique Devriese and Frank Piessens. 2011. On the Bright Side of Type Classes: Instance Arguments in Agda. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP ’11). 143–155. Google Scholar
Digital Library
- J. Nathan Foster, Michael B. Greenwald, Jonathan T. Moore, Benjamin C. Pierce, and Alan Schmitt. 2007. Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Transactions on Programming Languages and Systems 29, 3 (May 2007), 17. Google Scholar
Digital Library
- Oleg Kiselyov. 2014. The Design and Implementation of BER MetaOCaml. Springer International Publishing, Cham, 86–102. Google Scholar
Cross Ref
- Hsiang-Shang Ko. 2014. Analysis and synthesis of inductive families. DPhil dissertation. University of Oxford.Google Scholar
- Hsiang-Shang Ko and Jeremy Gibbons. 2013. Modularising inductive families. Progress in Informatics 10 (2013). Google Scholar
Cross Ref
- Hsiang-Shang Ko and Jeremy Gibbons. 2016. Programming with ornaments. Journal of Functional Programming 27 (2016). Google Scholar
Cross Ref
- Conor McBride. 2011. Ornamental Algebras, Algebraic Ornaments. (2011). https://personal.cis.strath.ac.uk/conor.mcbride/ pub/OAAO/LitOrn.pdfGoogle Scholar
- Trevor L. McDonell, Timothy A. K. Zakian, Matteo Cimini, and Ryan R. Newton. 2016. Ghostbuster: A Tool for Simplifying and Converting GADTs. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (ICFP 2016). ACM, New York, NY, USA, 338–350. Google Scholar
Digital Library
- Shayan Najd and Simon Peyton-Jones. 2016. Trees that grow. JUCS (2016). https://www.microsoft.com/en- us/research/ wp- content/uploads/2016/11/trees- that- grow- 2.pdfGoogle Scholar
- Chris Okasaki. 1998. Views for Standard ML. In In SIGPLAN Workshop on ML. 14–23.Google Scholar
- Scala. 2017. Implicit Parameters. Scala documentation. (2017). https://docs.scala- lang.org/tour/implicit- parameters.htmlGoogle Scholar
- Dimitrios Vytiniotis, Simon Peyton Jones, and Tom Schrijvers. 2010. Let Should Not Be Generalised, In Proceedings of the 5th ACM SIGPLAN Workshop on Types in Language Design and Implementation. https://www.microsoft.com/en- us/ research/publication/let- should- not- be- generalised/Google Scholar
Digital Library
- Philip Wadler. 1986. Views: A way for pattern matching to cohabit with data abstraction. (1986).Google Scholar
- Leo White, Frédéric Bour, and Jeremy Yallop. 2014. Modular implicits. In Proceedings ML Family/OCaml Users and Developers workshops, ML/OCaml 2014, Gothenburg, Sweden, September 4-5, 2014. 22–63. Google Scholar
Cross Ref
- Thomas Williams, Pierre-Évariste Dagand, and Didier Rémy. 2014. Ornaments in practice. In Proceedings of the 10th ACM SIGPLAN workshop on Generic programming, WGP 2014, Gothenburg, Sweden, August 31, 2014, José Pedro Magalhães and Tiark Rompf (Eds.). ACM, 15–24. Google Scholar
Digital Library
- Thomas Williams and Didier Rémy. 2017. A Principled Approach to Ornamentation in ML. Research Report RR-9117. Inria. https://hal.inria.fr/hal- 01628060Google Scholar
Index Terms
A principled approach to ornamentation in ML
Recommendations
Decidability of conversion for type theory in type theory
Type theory should be able to handle its own meta-theory, both to justify its foundational claims and to obtain a verified implementation. At the core of a type checker for intensional type theory lies an algorithm to check equality of types, or in ...
Ornaments: exploiting parametricity for safer, more automated code refactorization and code reuse (invited talk)
Haskell 2017: Proceedings of the 10th ACM SIGPLAN International Symposium on HaskellInductive datatypes and parametric polymorphism are two key features introduced in the ML family of languages, which have already been widely exploited for structuring programs: Haskell and ML programs are often more elegant and more correct by ...
Ornaments: exploiting parametricity for safer, more automated code refactorization and code reuse (invited talk)
Haskell '17Inductive datatypes and parametric polymorphism are two key features introduced in the ML family of languages, which have already been widely exploited for structuring programs: Haskell and ML programs are often more elegant and more correct by ...






Comments