Abstract

Type inference for parametric polymorphism is wildly successful, but has always suffered from an embarrassing flaw: polymorphic types are themselves not first class. We present Quick Look, a practical, implemented, and deployable design for impredicative type inference. To demonstrate our claims, we have modified GHC, a production-quality Haskell compiler, to support impredicativity. The changes required are modest, localised, and are fully compatible with GHC's myriad other type system extensions.

Highlights

  • Parametric polymorphism backed by Damas-Milner type inference was first introduced in ML [Milner 1978], and has been enormously influential and widely used

  • It has always suffered from an embarrassing shortcoming: Damas-Milner type inference, and its many variants, cannot instantiate a type variable with a polymorphic type; in the jargon, the system is predicative

  • The lack of impredicativity means that polymorphism is fundamentally second class: we cannot abstract over polymorphic types

Read more

Summary

A Quick Look at Impredicativity

ALEJANDRO SERRANO, 47 Degrees, Spain and Utrecht University, The Netherlands JURRIAAN HAGE, Utrecht University, The Netherlands SIMON PEYTON JONES, Microsoft Research, United Kingdom DIMITRIOS VYTINIOTIS, DeepMind, United Kingdom. Type inference for parametric polymorphism is wildly successful, but has always suffered from an embarrassing flaw: polymorphic types are themselves not first class. We present Quick Look, a practical, implemented, and deployable design for impredicative type inference. We have modified GHC, a production-quality Haskell compiler, to support impredicativity. The changes required are modest, localised, and are fully compatible with GHC’s myriad other type system extensions. CCS Concepts: · Theory of computation → Type structures. Additional Key Words and Phrases: Type systems, impredicative polymorphism, constraint-based inference. ACM Reference Format: Alejandro Serrano, Jurriaan Hage, Simon Peyton Jones, and Dimitrios Vytiniotis. Lang. 4, ICFP, Article 89 (August 2020), 29 pages. https://doi.org/10.1145/ 3408971

INTRODUCTION
MOTIVATION
THE QUICK LOOK
Quick Look at the Result
Richer Arguments
Uncurried Functions
Interim Summary
Bidirectional Typing Rules
Applications and Instantiation
QUICK LOOK IMPREDICATIVITY
A Quick Look at the Argument
Quick Look Unification
Guarded Arguments
Unguarded Arguments
Over-saturated Functions
Argument Order
Co- and Contravariance of Function Types
Modularity
Expressiveness and Backward Compatibility
Uniqueness of Quick Look
Inference Algorithm
EXTENDING THE LANGUAGE WITH QUALIFIED TYPES AND GADTS
IMPLEMENTATION
10 APPLICATIONS
11 RELATED WORK
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call