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.
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- A. Bove and V. Capretta. Modelling general recursion in type theory. Mathematical Structures in Computer Science, 15(4):671–708, Aug. 2005. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 2489840.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- D. R. Christiansen. Practical Reflection and Metaprogramming for Dependent Types. PhD thesis, IT University of Copenhagen, 2016.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- C. McBride. Dependently typed programs and their proofs. PhD thesis, University of Edinburgh, 1999.Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Elaborator reflection: extending Idris in Idris
Recommendations
Elaborator reflection: extending Idris in Idris
ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional ProgrammingMany 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 ...
Idris: general purpose programming with dependent types
PLPV '13: Proceedings of the 7th workshop on Programming languages meets program verificationIdris (http://idris-lang.org/) is a general purpose pure functional programming language with dependent types. Its syntax is influenced by Haskell and its features include full dependent types and records, type classes, tactic based theorem proving, ...
Idris: Implementing a Dependently Typed Programming Language
LFMTP '14: Proceedings of the 2014 International Workshop on Logical Frameworks and Meta-languages: Theory and PracticeIdris is a purely functional programming language with dependent types. As well as supporting theorem proving, Idris is intended to be a general purpose programming language. As such, it provides high-level concepts such as implicit syntax, type classes ...







Comments