July 26th, 2024

Evolving languages faster with type tailoring

A proposed solution called "type tailoring" enhances type systems using metaprogramming, allowing better type inference for constructs like regex. The approach aims to improve programming language usability and efficiency.

Read original articleLink Icon
Evolving languages faster with type tailoring

Programming languages often evolve slowly, particularly in their type systems, which struggle to accommodate domain-specific constructs like regular expressions and SQL queries. This limitation forces programmers to handle type-checking manually, leading to cumbersome code. A proposed solution is "type tailoring," a concept introduced in a paper accepted at the European Conference on Object-Oriented Programming (ECOOP). Type tailoring allows programmers to enhance type systems using metaprogramming tools, enabling them to teach the type checker about specific constructs without altering the underlying language or compiler.

The paper outlines a high-level approach to type tailoring, where the type system can recognize the structure of regex captures, allowing for more accurate type inference. The authors present the "trivial library" for Typed Racket, which automates the insertion of necessary type checks and casts, streamlining the coding process. Essential features for effective type tailoring include type checking after elaboration, elaboration-time computation, and the use of abstract syntax trees (ASTs).

The authors also highlight existing projects that exemplify type tailoring, such as Rust's SQLx library and Julia's StaticArrays package. By defining type tailoring and identifying its key components, the paper aims to unify various efforts across programming languages and encourage further development in this area. The authors anticipate that their work will inspire more libraries and tools that leverage type tailoring to improve programming language usability and efficiency.

Link Icon 1 comments
By @ashton314 - 3 months
Author here! I got invited to repost this for a go at the 2nd-chance pool. (Thanks mods!) I’m happy to answer anyone’s questions. :)