type-checking

Implementing Type Systems as Macros

14 Aug 2023
featured
computer-science, programming-languages, macros, type-checking

There’s a neat paper Type Systems as Macros by Chang, Knauth, and Greenman [1] that describes how to implement a typed language using an untyped host language and macro expansion. The paper is neat, but I found the code hard to follow—the paper uses a compact notation that’s convenient for print, but not so much for reproducing on one’s own. This post is my attempt to implement and explain in more accessible terms what’s presented in the paper. ...

What is a type system, really?

23 Jan 2023
featured
computer-science, programming-languages, type-checking

Background # This is a question I’ve been wrestling with for a little bit. My first experience with a type system was with Java, and I didn’t like it. It just felt like an annoying constraint on the kinds of programs I could write. I was coming from Perl, which sports weak dynamic typing, so Java’s rigidity came as a bit of a shock. After Java I learned some C, which too has types. ...

How to write a type checker/type inferrer with good error messages

27 Jul 2022
featured, tutorials
programming-languages, type-checking, computer-science

All the source for this may be found on my SourceHut repository. Synopsis # Experimental type checker/inferer for a simple lambda calculus Description # This is a type inference system for a little language. (Described below.) It uses a fusion of type inference algorithms from PLAI, ESP, and μKanren. (See Resources) Broadly speaking, our type inference engine works by: generating typing constraints from the program solving those constraints We’ll describe each of those in more detail. ...

Mastodon