kirancodes.me
To Proof Maintenance & Beyond!

Coercive Subtyping for Implicit Functorial Programming

Ryan Doenges, Caden Parajuli, Ayden Lamparski, Ke Wu, Aaron Stump

Abstract

Programming with typeclass-defined combinators like fmap allows programs a great deal of generality and concision, but programmers have to explicitly invoke combinators in the right places in order to get their programs to type check. In this paper, we propose inferring these operations using a coercive subtyping discipline and study the metatheory of the resulting algebra of coercions. For functors, we promote the fmap combinator of type (A → B) → F A → F B to a coercion A → B ≤ F A → F B. We incorporate it into a monomorphic system of coercions for base types, arrow types, and functor types. We prove that the resulting system of coercions is coherent, meaning that all possible choices of coercions from A to B end up equivalent. The proof of the theorem is based on coherence by evaluation, an approach to coherence proofs based on the well-known technique of normalization by evaluation. All definitions and theorems in the paper are checked in Agda, which played a valuable role in the design of the system.

DOI 10.1145/3830439.3831273

Related papers