Moebius: Metaprogramming using Contextual Types -- The stage where System F can pattern match on itself (Long Version)
Junyoung Jang, Samuel G\'elineau, Stefan Monnier, Brigitte, Pientka

TL;DR
Moebius introduces a type-theoretic foundation for metaprogramming that enables polymorphic code generation and pattern matching with strong type guarantees, advancing the reliability and expressiveness of multi-staged programming.
Contribution
It develops a multi-level modal lambda-calculus with pattern matching support for polymorphic code, extending System F and providing operational semantics with type preservation.
Findings
Supports open code with context-dependent variables
Enforces strong type guarantees during code manipulation
Provides a formal foundation for reliable multi-staged metaprogramming
Abstract
We describe the foundation of the metaprogramming language, Moebius, which supports the generation of polymorphic code and, more importantly the analysis of polymorphic code via pattern matching. Moebius has two main ingredients: 1) we exploit contextual modal types to describe open code together with the context in which it is meaningful. In Moebius, open code can depend on type and term variables (level 0) whose values are supplied at a later stage, as well as code variables (level 1) that stand for code templates supplied at a later stage. This leads to a multi-level modal lambda-calculus that supports System-F style polymorphism and forms the basis for polymorphic code generation. 2) we extend the multi-level modal lambda-calculus to support pattern matching on code. As pattern matching on polymorphic code may refine polymorphic type variables, we extend our type-theoretic…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLogic, programming, and type systems · Formal Methods in Verification · Software Testing and Debugging Techniques
