ABSTRACT
Dependently typed languages with an "open" type theory introduce new datatypes using an axiomatic approach. Each new datatype introduces axioms for constructing values of the datatype, and an elimination axiom (which we call the standard eliminator) for consuming such values. In a "closed" type theory a single introduction rule primitive and a single elimination rule primitive can be used for all datatypes, without adding axioms to the theory.
We review a closed type theory, specified as an Agda program, that uses descriptions for datatype construction. Descriptions make datatype definitions first class values, but writing programs using such datatypes requires low-level understanding of how the datatypes are encoded in terms of descriptions. In this work we derive constructors and standard eliminators, by defining generic functions parameterized by a description. Our generic type theory constructions are defined as generic wrappers around the closed type theory primitives, which are themselves generic functions in the Agda model. Thus, we allow users to write programs in the model without understanding the details of the description-based encoding of datatypes, by using open type theory constructions as an internal domain-specific language (IDSL).
- R. Atkey. A type checker that knows its monad from its elbow. blog post, Dec. 2011. URL http://bentnib.org/posts/2011-12-14-type-checker.html.Google Scholar
- E. C. Brady. Idris -- systems programming meets full dependent types. In Proceedings of the 5th ACM workshop on Programming languages meets program verification, pages 43--54. ACM, 2011. Google ScholarDigital Library
- J. Chapman, P.-E. Dagand, C. McBride, and P. Morris. The gentle art of levitation. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP '10, pages 3--14, New York, NY, USA, 2010. ACM. ISBN 978-1-60558-794-3. 10.1145/1863543.1863547. URL http://doi.acm.org/10.1145/1863543.1863547. Google ScholarDigital Library
- A. Chlipala. Certified programming with dependent types, 2011. Google ScholarDigital Library
- P.-E. Dagand. A Cosmology of Datatypes. PhD thesis, University of Strathclyde, 2013.Google Scholar
- P.-E. Dagand and C. McBride. Transporting functions across ornaments. In Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming, ICFP '12, pages 103--114, New York, NY, USA, 2012. ACM. ISBN 978-1-4503-1054-3. 10.1145/2364527.2364544. URL http://doi.acm.org/10.1145/2364527.2364544. Google ScholarDigital Library
- E. Giménez. Codifying guarded definitions with recursive schemes. In Types for proofs and Programs, pages 39--59. Springer, 1995. Google ScholarDigital Library
- S. L. P. Jones. Haskell 98 language and libraries: the revised report. Cambridge University Press, 2003.Google Scholar
- P. J. Landin. The next 700 programming languages. Communications of the ACM, 9 (3): 157--166, 1966. Google ScholarDigital Library
- P. Martin-Löf. An intuitionistic theory of types: Predicative part. Studies in Logic and the Foundations of Mathematics, 80: 73--118, 1975.Google ScholarCross Ref
- C. McBride. Elimination with a motive. In Selected papers from the International Workshop on Types for Proofs and Programs, TYPES '00, pages 197--216, London, UK, UK, 2002. Springer-Verlag. ISBN 3-540-43287-6. URL http://dl.acm.org/citation.cfm?id=646540.759262. Google ScholarDigital Library
- C. McBride. Epigram: Practical programming with dependent types. In Advanced Functional Programming, pages 130--170. Springer, 2005. Google ScholarDigital Library
- C. McBride. Ornamental algebras, algebraic ornaments. 2011.Google Scholar
- C. McBride, H. Goguen, and J. McKinna. A few constructions on constructors. In Types for Proofs and Programs, pages 186--200. Springer, 2006. Google ScholarDigital Library
- U. Norell. Towards a practical programming language based on dependent type theory. Chalmers University of Technology, 2007.Google Scholar
- The Coq Development Team. The Coq Proof Assistant Reference Manual, 2008. URL http://coq.inria.fr.Google Scholar
Index Terms
Generic constructors and eliminators from descriptions: type theory as a dependently typed internal DSL
Recommendations
Generic zero-cost reuse for dependent types
Dependently typed languages are well known for having a problem with code reuse. Traditional non-indexed algebraic datatypes (e.g. lists) appear alongside a plethora of indexed variations (e.g. vectors). Functions are often rewritten for both non-...
Practical generic programming over a universe of native datatypes
Datatype-generic programming makes it possible to define a construction once and apply it to a large class of datatypes.
It is often used to avoid code duplication in languages that encourage the definition of custom datatypes, in particular state-...
Outrageous but meaningful coincidences: dependent type-safe syntax and evaluation
WGP '10: Proceedings of the 6th ACM SIGPLAN workshop on Generic programmingTagless interpreters for well-typed terms in some object language are a standard example of the power and benefit of precise indexing in types, whether with dependent types, or generalized algebraic datatypes. The key is to reflect object language types ...
Comments