skip to main content
article
Public Access

Elaborator reflection: extending Idris in Idris

Published:04 September 2016Publication History
Skip Abstract Section

Abstract

Many programming languages and proof assistants are defined by elaboration from a high-level language with a great deal of implicit information to a highly explicit core language. In many advanced languages, these elaboration facilities contain powerful tools for program construction, but these tools are rarely designed to be repurposed by users. We describe elaborator reflection, a paradigm for metaprogramming in which the elaboration machinery is made directly available to metaprograms, as well as a concrete realization of elaborator reflection in Idris, a functional language with full dependent types. We demonstrate the applicability of Idris’s reflected elaboration framework to a number of realistic problems, we discuss the motivation for the specific features of its design, and we explore the broader meaning of elaborator reflection as it can relate to other languages.

References

  1. T. Altenkirch and C. McBride. Generic programming within dependently typed programming. In Proceedings of IFIP TC2/WG2.1 Working Conference on Generic Programming, Schloss Dagstuhl, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. D. Aspinall. Proof General: A generic tool for proof development. In Proceedings of the 6th International Conference on Tools and Algorithms for the Construction and Analysis of Systems, TACAS 2000, pages 38–43. Springer Berlin Heidelberg, 2000. doi: 10.1007/3-540-46419-0 3. R. Atkey. An Algebraic Approach To Typechecking and Elaboration. Talk at Higher Order Programming with Effects (HOPE), 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. M. Benke, P. Dybjer, and P. Jansson. Universes for generic programs and proofs in dependent type theory. Nordic Journal of Computing, 10(4): 265–289, Dec. 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. Bove and V. Capretta. Modelling general recursion in type theory. Mathematical Structures in Computer Science, 15(4):671–708, Aug. 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. E. Brady. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming, 23 (05):552–593, 2013. doi: 10.1017/S095679681300018X. E. Brady and K. Hammond. Scrapping your inefficient engine: using partial evaluation to improve domain-specific language implementation. In Proceeding of the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP ’10, pages 297–308. ACM, 2010. doi: 10.1145/1863543.1863587. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. E. Brady, C. McBride, and J. McKinna. Inductive families need not store their indices. In S. Berardi, M. Coppo, and F. Damiani, editors, Types for Proofs and Programs, International Workshop, TYPES 2003, volume 3085 of Lecture Notes in Computer Science, pages 115–129. Springer, 2003. doi: 10.1007/978-3-540-24849-1 8. E. Burmako. Scala macros: Let our powers combine!: On how rich syntax and static types work with metaprogramming. In Proceedings of the 4th Workshop on Scala, SCALA ’13. ACM, 2013. doi: 10.1145/2489837. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 2489840.Google ScholarGoogle Scholar
  8. 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. ACM, 2010. doi: 10.1145/1863543.1863547. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. A. Chlipala. Certified Programming with Dependent Types. MIT Press, 2011. Available online: http://adam.chlipala.net/cpdt/. D. R. Christiansen. Dependent type providers. In Proceedings of the 9th ACM SIGPLAN Workshop on Generic Programming, WGP ’13, pages 25– 34, New York, NY, USA, 2013. ACM. doi: 10.1145/2502488.2502495. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. D. R. Christiansen. Type-directed elaboration of quasiquotations: A highlevel syntax for low-level reflection. In Proceedings of the 26th International Symposium on Implementation and Application of Functional Languages, IFL ’14, October 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. D. R. Christiansen. Practical Reflection and Metaprogramming for Dependent Types. PhD thesis, IT University of Copenhagen, 2016.Google ScholarGoogle Scholar
  12. D. Delahaye. A tactic language for the system Coq. In Proceedings of the 7th International Conference on Logic for Programming and Automated Reasoning, LPAR’00, pages 85–95, Berlin, Heidelberg, 2000. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. D. Devriese and F. Piessens. Typed syntactic meta-programming. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP ’13, pages 73–86, New York, NY, USA, 2013. ACM. doi: 10.1145/2500365.2500575. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. P. Dybjer. A general formulation of simultaneous inductive-recursive definitions in type theory. The Journal of Symbolic Logic, 65:525–549, 6 2000. doi: 10.2307/2586554.Google ScholarGoogle ScholarCross RefCross Ref
  15. P. Dybjer and A. Setzer. A finite axiomatization of inductive-recursive definitions. In J. Girard, editor, Proceedings of the 4th International Conference on Typed Lambda Calculi and Applications, TLCA’99, volume 1581 of TLCA ’99, pages 129–146. Springer, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. doi: 10.1007/3-540-48959-2 11. M. Flatt. Composable and compilable macros:: You want it when? In Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming, ICFP ’02, pages 72–83, New York, NY, USA, 2002. ACM. doi: 10.1145/581478.581486. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. C. McBride. Dependently typed programs and their proofs. PhD thesis, University of Edinburgh, 1999.Google ScholarGoogle Scholar
  18. C. McBride. Turing-completeness totally free. In R. Hinze and J. Voigtländer, editors, Proceedings of Mathematics of Program Construction: 12th International Conference, MPC 2015, pages 257–275. Springer International Publishing, 2015. doi: 10.1007/978-3-319-19797-5 13. U. Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Department of Computer Science and Engineering, Chalmers University of Technology, Göteborg, Sweden, September 2007.Google ScholarGoogle Scholar
  19. U. Norell and P. Jansson. Prototyping generic programming in Template Haskell. In D. Kozen, editor, Mathematics of Program Construction, volume 3125 of LNCS, pages 314–333. Springer-Verlag, 2004. doi: 10.1007/978-3-540-27764-4 17. T. Sheard and S. P. Jones. Template meta-programming for Haskell. In Proceedings of the 2002 ACM SIGPLAN Workshop on Haskell, Haskell ’02, pages 1–16. ACM, 2002. doi: 10.1145/581690.581691. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. N. Swamy, C. Hrit¸cu, C. Keller, A. Rastogi, A. Delignat-Lavaud, S. Forest, K. Bhargavan, C. Fournet, P.-Y. Strub, M. Kohlweiss, J.-K. Zinzindohoue, and S. Zanella-Béguelin. Dependent types and multi-monadic effects in F*. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pages 256–270. ACM, 2016. doi: 10.1145/2837614.2837655. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. D. Syme, K. Battocchi, K. Takeda, D. Malayeri, and T. Petricek. Themes in information-rich functional programming for Internet-scale data sources. In Proceedings Workshop on Data Driven Functional Programming, DDFP 2013, 2013. doi: 10.1145/2429376.2429378. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. P. van der Walt and W. Swierstra. Engineering proof by reflection in Agda. In R. Hinze, editor, 24th International Symposium on Implementation and Application of Functional Languages, volume 8241 of Lecture Notes in Computer Science. Springer Berlin Heidelberg, 2012. doi: 10.1007/978-3-642-41582-1 10. D. Vytiniotis, S. L. P. Jones, T. Schrijvers, and M. Sulzmann. OutsideIn(X): Modular type inference with local assumptions. Journal of Functional Programming, 21(4-5):333–412, 2011. doi: 10.1017/ S0956796811000098. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. B. Ziliani, D. Dreyer, N. R. Krishnaswami, A. Nanevski, and V. Vafeiadis. Mtac: A monad for typed tactic programming in Coq. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP ’13, pages 87–100. ACM, 2013. doi: 10.1145/ 2500365.2500579. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Elaborator reflection: extending Idris in Idris

    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

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 51, Issue 9
      ICFP '16
      September 2016
      501 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/3022670
      Issue’s Table of Contents
      • cover image ACM Conferences
        ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming
        September 2016
        501 pages
        ISBN:9781450342193
        DOI:10.1145/2951913

      Copyright © 2016 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 4 September 2016

      Check for updates

      Qualifiers

      • article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!