In type theory, a refinement type[1][2][3] is a type endowed with a predicate which is assumed to hold for any element of the refined type. Refinement types can express preconditions when used as function arguments or postconditions when used as return types: for instance, the type of a function which accepts natural numbers and returns natural numbers greater than 5 may be written as . Refinement types are thus related to behavioral subtyping.
History
The concept of refinement types was first introduced in Freeman and Pfenning's 1991 Refinement types for ML,[1] which presents a type system for a subset of Standard ML. The type system "preserves the decidability of ML's type inference" whilst still "allowing more errors to be detected at compile-time". In more recent times, refinement type systems have been developed (primary in academia) for languages such as Haskell,[4][5]TypeScript,[6]Rust,[7] and as libraries for real world usage in Scala.[8][9]
See also
References
- 12Freeman, T.; Pfenning, F. (1991). "Refinement types for ML"(PDF). Proceedings of the ACM Conference on Programming Language Design and Implementation. pp. 268–277. doi:10.1145/113445.113468.
- ↑Hayashi, S. (1993). "Logic of refinement types". Proceedings of the Workshop on Types for Proofs and Programs. pp. 157–172. CiteSeerX 10.1.1.38.6346. doi:10.1007/3-540-58085-9_74.
- ↑Denney, E. (1998). "Refinement types for specification". Proceedings of the IFIP International Conference on Programming Concepts and Methods. Vol. 125. Chapman & Hall. pp. 148–166. CiteSeerX 10.1.1.22.4988.
- ↑ Vazou, Niki. Liquid Haskell: Tipos de refinamiento para Haskell . 45.º Simposio ACM SIGPLAN sobre Principios de Lenguajes de Programación (POPL 2018).
- ↑ Volkov, Nikita (2015). "Tipos de refinamiento como una biblioteca de Haskell" .
- ↑ Panagiotis, Vekris; Cosman, Benjamin; Jhala, Ranjit (2016). "Tipos de refinamiento para TypeScript". Actas de la 37.ª Conferencia ACM SIGPLAN sobre diseño e implementación de lenguajes de programación . págs. 310–325 . arXiv : 1604.02480 . doi : 10.1145/2908080.2908110 .
- ↑ Lehmann, Nico; Geller, Adam T.; Vazou, Niki; Jhala, Ranjit (6 de junio de 2023). "Flux: Liquid Types for Rust" . Actas de la ACM sobre lenguajes de programación . 7 (PLDI): 169:1533–169:1557. doi : 10.1145/3591283 .
- ↑ Thomas, Frank (2025-09-08). "refined: tipos de refinamiento simples para Scala" . GitHub . Archivado del original el 2025-08-21 . Recuperado el 2025-09-08 .
- ↑ Fromentin, Raphaël (2025-09-08). "Restricciones de tipo fuertes para Scala" . GitHub . Archivado del original el 2025-05-20 . Recuperado el 2025-09-08 .
- teoría de tipos
- Sistemas de tipos
- Esbozos de teoría de lenguajes de programación