Inferring Typing Rules for Contextual Sugars

View at publisher
Authors: Tailai Yu, Zhichao Guan, Di Wang, Zhenjiang Hu
Cited by: 0
References: 15

Abstract

Syntactic sugars ease the definition of new language constructs by transforming them into an existing core language. Previous works lift independent typing rules and other semantics for these new constructs from the core language. The lifted semantics preserve the abstraction boundary of syntactic sugars, freeing users from inspecting desugared code that they did not write. While sugars may interact with contextual information during desugaring in general, these works are limited to simple sugars that do not. We identify a class of contextual sugars and present an extended algorithm for lifting their typing rules. With the addition of contexts, naïvely representing desugaring results in the core language may cause unexpected behavior and break hygiene. We introduce anchored terms that can point to the provenance of their contexts to represent desugaring results, which is similar to mechanisms used in Racket macros. Anchored terms need not concern authors or users of contextual sugars, but enable local reasoning. The lifted typing rules are sound with respect to the typing of anchored core language terms.

Fields of Study & Subjects

Logic programming and type systems Software Engineering Research Usability and User Interface Design

Publication details

Pages
61–75
Publication date
8 January 2026