skip to main content
10.1145/2633628.2633630acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Generic constructors and eliminators from descriptions: type theory as a dependently typed internal DSL

Published:26 August 2014Publication History

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).

References

  1. 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 ScholarGoogle Scholar
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. Chlipala. Certified programming with dependent types, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. P.-E. Dagand. A Cosmology of Datatypes. PhD thesis, University of Strathclyde, 2013.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. E. Giménez. Codifying guarded definitions with recursive schemes. In Types for proofs and Programs, pages 39--59. Springer, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. S. L. P. Jones. Haskell 98 language and libraries: the revised report. Cambridge University Press, 2003.Google ScholarGoogle Scholar
  9. P. J. Landin. The next 700 programming languages. Communications of the ACM, 9 (3): 157--166, 1966. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. P. Martin-Löf. An intuitionistic theory of types: Predicative part. Studies in Logic and the Foundations of Mathematics, 80: 73--118, 1975.Google ScholarGoogle ScholarCross RefCross Ref
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. C. McBride. Epigram: Practical programming with dependent types. In Advanced Functional Programming, pages 130--170. Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. C. McBride. Ornamental algebras, algebraic ornaments. 2011.Google ScholarGoogle Scholar
  14. C. McBride, H. Goguen, and J. McKinna. A few constructions on constructors. In Types for Proofs and Programs, pages 186--200. Springer, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. U. Norell. Towards a practical programming language based on dependent type theory. Chalmers University of Technology, 2007.Google ScholarGoogle Scholar
  16. The Coq Development Team. The Coq Proof Assistant Reference Manual, 2008. URL http://coq.inria.fr.Google ScholarGoogle Scholar

Index Terms

  1. Generic constructors and eliminators from descriptions: type theory as a dependently typed internal DSL

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Conferences
        WGP '14: Proceedings of the 10th ACM SIGPLAN workshop on Generic programming
        August 2014
        102 pages
        ISBN:9781450330428
        DOI:10.1145/2633628
        • Program Chairs:
        • José Pedro Magalhäes,
        • Tiark Rompf

        Copyright © 2014 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 26 August 2014

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        WGP '14 Paper Acceptance Rate8of9submissions,89%Overall Acceptance Rate30of43submissions,70%

        Upcoming Conference

        ICFP '24

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader