Intensional Datatype Refinement
Abstract
The pattern-match safety problem is to verify that a given functional program will never crash due to non-exhaustive patterns in its function definitions. We present a refinement type system that can be used to solve this problem. The system extends ML-style type systems with algebraic datatypes by a limited form of structural subtyping and environment-level intersection. We describe a fully automatic, sound and complete type inference procedure for this system which, under reasonable assumptions, is worst-case linear-time in the program size. Compositionality is essential to obtaining this complexity guarantee. A prototype implementation for Haskell is able to analyse a selection of packages from the Hackage database in a few hundred milliseconds.
- Publication:
-
arXiv e-prints
- Pub Date:
- August 2020
- DOI:
- 10.48550/arXiv.2008.01452
- arXiv:
- arXiv:2008.01452
- Bibcode:
- 2020arXiv200801452J
- Keywords:
-
- Computer Science - Programming Languages;
- F.3.1
- E-Print:
- 26 pages plus bibliography and appendices. Tool available from https://github.com/bristolpl/intensional-datatys. [v2] fixed accidental unicode-related formatting issues in bibliography. [v3] Improvements incorporated, thanks to POPL 2021 reviewers