1. 10

Static typing can guide programmers if feedback is immediate. Therefore, all major IDEs incrementalize type checking in some way. However, prior approaches to incremental type checking are often specialized and hard to transfer to new type systems. In this paper, we propose a systematic approach for deriving incremental type checkers from textbook-style type system specifications. Our approach is based on compiling inference rules to Datalog, a carefully limited logic programming language for which incremental solvers exist. The key contribution of this paper is to discover an encoding of the infinite typing relation as a finite Datalog relation in a way that yields efficient incremental updates. We implemented the compiler as part of a type system DSL and show that it supports simple types, some local type inference, operator overloading, universal types, and iso-recursive types.

    1. 6

      I’m posting it because it deals with my question of “can you write a type checker in datalog?”, as investigated here: https://lobste.rs/s/ky4li4/simply_typed_lambda_calculus_datalog . The answer is kinda “no, but yes”: once you get to System F’s generics/universal types, you need a “substitution” operator that you cannot write in Datalog. They deal with it by having the DL rule for that notice (somehow), performing the operation in another language (Java I think in their case), and feeding the altered AST info back into Datalog to pick up where it left off. Which apparently works! I just, you know, kinda don’t want to do it.

      I’m just excited to have someone else run into the same problem and draw the same conclusion that I did!

      Then there’s also this: https://www.mbid.me/posts/type-checking-with-eqlog-types/, which does apparently typecheck System F in an extended variant of Datalog, but which I am still trying to chug my way through to figure out how the heck it works.