Gradual liquid type inference - Archive ouverte HAL Accéder directement au contenu
Article Dans Une Revue Proceedings of the ACM on Programming Languages Année : 2018

Gradual liquid type inference

Résumé

Refinement types allow for lightweight program verification by enriching types with logical predicates. Liquid typing provides a decidable refinement inference mechanism that is convenient but subject to two major issues: (1) inference is global and requires top-level annotations, making it unsuitable for inference of modular code components and prohibiting its applicability to library code, and (2) inference failure results in obscure error messages. These difficulties seriously hamper the migration of existing code to use refinements. This paper shows that gradual liquid type inference–a novel combination of liquid inference and gradual refinement types–addresses both issues. Gradual refinement types, which support imprecise predicates that are optimistically interpreted, can be used in argument positions to constrain liquid inference so that the global inference process effectively infers modular specifications usable for library components. Dually, when gradual refinements appear as the result of inference, they signal an inconsistency in the use of static refinements. Because liquid refinements are drawn from a finite set of predicates, in gradual liquid type inference we can enumerate the textitsafe concretizations of each imprecise refinement, i.e., the static refinements that justify why a program is gradually well-typed. This enumeration is useful for static liquid type error explanation, since the safe concretizations exhibit all the potential inconsistencies that lead to static type errors. We develop the theory of gradual liquid type inference and explore its pragmatics in the setting of Liquid Haskell. To demonstrate the utility of our approach, we develop an interactive tool, GuiLT, for gradual liquid type inference in Liquid Haskell that both infers modular types and explores safe concretizations of gradual refinements. We report on the use of GuiLT for error reporting and discuss a case study on the migration of three commonly-used Haskell list manipulation libraries into Liquid Haskell.

Dates et versions

hal-01949207 , version 1 (09-12-2018)

Licence

Paternité

Identifiants

Citer

Niki Vazou, Éric Tanter, David van Horn. Gradual liquid type inference. Proceedings of the ACM on Programming Languages, 2018, 2 (OOPSLA), pp.1-25. ⟨10.1145/3276502⟩. ⟨hal-01949207⟩
46 Consultations
0 Téléchargements

Altmetric

Partager

Gmail Facebook X LinkedIn More