Context
This is one of my favourite papers because itβs such a great hack, and reminds me of a bunch of statics-as-macros style tricks that we used in Witchcraft. I need to double check this, but IIRC this is also how [[core.typed
]] was implemented in Clojure.
Abstract
Abstract
We present TURNSTILE, a metalanguage for creating typed embedded languages. To implement the type system, programmers write type checking rules resembling traditional judgment syntax. To implement the semantics, they incorporate elaborations into these rules. TURNSTILE critically depends on the idea of linguistic reuse. It exploits a macro system in a novel way to simultaneously type check and rewrite a surface program into a target language. Reusing a macro system also yields modular implementations whose rules may be mixed and matched to create other languages. Combined with typical compiler and runtime reuse, TURNSTILE produces performant typed embedded languages with little effort.
Notes
Quote
we really donβt want to build a programming language from scratch β¦ better, letβs inherit the infrastructure of some other language
β Paul Hudak
- A macro system runs early in the compilation process
- This is also where type systems tend to run in the compilation pipeline.
- Interleaved type checking and rewriting
- Much emphasis on good error messages
- Can use macros to reuse parts of the parent type system
- They donβt show it explicitly in the paper, but mention that one could use this to define an effect system.
Turnstile
Turnstile is a metalanguage that has Bidirectional typing, though with different syntax that you often see elsewhere:
Turnstile | Meaning | Pfenning |
---|---|---|
Check | ||
Synthesise | ||
expands to | N/A |
They go further to include existentials, kindedness, and higher order polymorphism akin to System .