Abstract
A linear parameter must be consumed exactly once in the body of its function. When declaring resources such as file handles and manually managed memory as linear arguments, a linear type system can verify that these resources are used safely. However, writing code with explicit linear arguments requires bureaucracy. This paper presents linear constraints, a front-end feature for linear typing that decreases the bureaucracy of working with linear types. Linear constraints are implicit linear arguments that are filled in automatically by the compiler. We present linear constraints as a qualified type system,together with an inference algorithm which extends GHC's existing constraint solver algorithm. Soundness of linear constraints is ensured by the fact that they desugar into Linear Haskell.
- Andreas Abel and Jean-Philippe Bernardy. 2020. A unified view of modalities in type systems. Proceedings of the ACM on Programming Languages, 4, ICFP (2020).
Google Scholar
Digital Library
- Jean-Philippe Bernardy, Mathieu Boespflug, Ryan R. Newton, Simon Peyton Jones, and Arnaud Spiwack. 2017. Linear Haskell: Practical Linearity in a Higher-order Polymorphic Language. Proc. ACM Program. Lang., 2, POPL (2017), Article 5, Dec., 29 pages. issn:2475-1421 https://doi.org/10.1145/3158093
Google Scholar
Digital Library
- Gert-Jan Bottu, Georgios Karachalias, Tom Schrijvers, Bruno C. d. S. Oliveira, and Philip Wadler. 2017. Quantified Class Constraints. In Proceedings of the 10th ACM SIGPLAN International Symposium on Haskell (Haskell 2017). Association for Computing Machinery, New York, NY, USA. 148–161. isbn:9781450351829 https://doi.org/10.1145/3122955.3122967
Google Scholar
Digital Library
- Iliano Cervesato, Joshua S. Hodas, and Frank Pfenning. 2000. Efficient resource management for linear logic proof search. Theoretical Computer Science, 232, 1 (2000), 133 – 163. issn:0304-3975 https://doi.org/10.1016/S0304-3975(99)00173-5
Google Scholar
Digital Library
- Karl Crary, David Walker, and J. Gregory Morrisett. 1999. Typed Memory Management in a Calculus of Capabilities. In POPL ’99, Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, San Antonio, TX, USA, January 20-22, 1999, Andrew W. Appel and Alex Aiken (Eds.). ACM, 262–275. https://doi.org/10.1145/292540.292564
Google Scholar
Digital Library
- Vincent Danos, Jean Baptiste Joinet, and Harold Schellinx. 1993. The structure of exponentials: Uncovering the dynamics of linear logic proofs. In Computational Logic and Proof Theory, Georg Gottlob, Alexander Leitsch, and Daniele Mundici (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 159–171. isbn:978-3-540-47943-7
Google Scholar
- Robert DeLine and Manuel Fähndrich. 2001. Enforcing High-Level Protocols in Low-Level Software. In Proceedings of the 2001 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Snowbird, Utah, USA, June 20-22, 2001, Michael Burke and Mary Lou Soffa (Eds.). ACM, 59–69. https://doi.org/10.1145/378795.378811
Google Scholar
Digital Library
- Facundo Domínguez. 2020. Safe memory management in inline-java using linear types. https://web.archive.org/web/20200926082552/https://www.tweag.io/blog/2020-02-06-safe-inline-java/ Blog post
Google Scholar
- Richard A. Eisenberg, Guillaume Duboc, Stephanie Weirich, and Daniel Lee. 2021. An Existential Crisis Resolved: Type inference for first-class existential types. Proc. ACM Program. Lang., 5, ICFP (2021).
Google Scholar
Digital Library
- Richard A. Eisenberg, Stephanie Weirich, and Hamidhasan G. Ahmed. 2016. Visible Type Application. In Programming Languages and Systems, Peter Thiemann (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 229–254. isbn:978-3-662-49498-1
Google Scholar
- Matthew Fluet, Greg Morrisett, and Amal J. Ahmed. 2006. Linear Regions Are All You Need. In Programming Languages and Systems, 15th European Symposium on Programming, ESOP 2006, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2006, Vienna, Austria, March 27-28, 2006, Proceedings, Peter Sestoft (Ed.) (Lecture Notes in Computer Science, Vol. 3924). Springer, 7–21. https://doi.org/10.1007/11693024_2
Google Scholar
Digital Library
- Jean-Yves Girard. 1987. Linear logic. Theoretical Computer Science, 50, 1 (1987), 1–101. issn:0304-3975 https://doi.org/10.1016/0304-3975(87)90045-4
Google Scholar
Digital Library
- Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. 1996. Type Classes in Haskell. ACM Trans. Program. Lang. Syst., 18, 2 (1996), March.
Google Scholar
Digital Library
- J.S. Hodas and D. Miller. 1994. Logic Programming in a Fragment of Intuitionistic Linear Logic. Information and Computation, 110, 2 (1994), 327 – 365. issn:0890-5401 https://doi.org/inco.1994.1036
Google Scholar
Digital Library
- Joshua Seth Hodas. 1994. Logic programming in intuitionistic linear logic: Theory, design, and implementation. https://repository.upenn.edu/dissertations/AAI9427546
Google Scholar
- Mark P. Jones. 1994. A theory of qualified types. Science of Computer Programming, 22, 3 (1994), 231 – 256. issn:0167-6423 https://doi.org/10.1016/0167-6423(94)00005-0
Google Scholar
Digital Library
- Csongor Kiss, Arnaud Spiwack, Jean-Philippe Bernardy, Nicolas Wu, and Richard A. Eisenberg. 2022. Prototype implementation of linear constraints in GHC. http://archive.softwareheritage.org/swh:1:rev:f6fc5ba23770b42d1d6020e177787757b16a9ea0;origin=https://github.com/kcsongor/ghc;visit=swh:1:snp:aa61d803eaec9eb4425e3eb8ed2b0fbbd60633cc Code fragment
Google Scholar
- Naoki Kobayashi, Benjamin C. Pierce, and David N. Turner. 1999. Linearity and the Pi-Calculus. ACM Trans. Program. Lang. Syst., 21, 5 (1999), Sept., 914–947. issn:0164-0925 https://doi.org/10.1145/330249.330251
Google Scholar
Digital Library
- Kazutaka Matsuda. 2020. Modular Inference of Linear Types for Multiplicity-Annotated Arrows. In Programming Languages and Systems, Peter Müller (Ed.). Springer International Publishing, Cham. 456–483. isbn:978-3-030-44914-8
Google Scholar
- Dale A. Miller, Gopalan Nadathur, and Andre Scedrov. 1987. Hereditary Harrop Formulas and Uniform Proof Systems. In Proceedings of the Second Annual IEEE Symposium on Logic in Computer Science (LICS 1987). IEEE Computer Society Press, 98–105.
Google Scholar
- Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. 2007. Practical type inference for arbitrary-rank types. Journal of Functional Programming, 17, 1 (2007), 1–82. https://doi.org/10.1017/S0956796806006034
Google Scholar
Digital Library
- Benjamin C. Pierce. 2002. Types and Programming Languages. MIT Press, Cambridge, MA.
Google Scholar
Digital Library
- François Pottier and Jonathan Protzenko. 2013. Programming with Permissions in Mezzo. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP ’13). Association for Computing Machinery, New York, NY, USA. 173–184. isbn:9781450323260 https://doi.org/10.1145/2500365.2500598
Google Scholar
Digital Library
- François Pottier and Didier Rémy. 2005. The essence of ML type inference.
Google Scholar
- Gabriel Radanne, Hannes Saffrich, and Peter Thiemann. 2020. Kindly Bent to Free Us. Proc. ACM Program. Lang., 4, ICFP (2020), Article 103, Aug., 29 pages. https://doi.org/10.1145/3408985
Google Scholar
Digital Library
- Michael Shulman. 2018. Linear logic for constructive mathematics. arxiv:1805.07518.
Google Scholar
- Frederick Smith, David Walker, and J. Gregory Morrisett. 2000. Alias Types. In Programming Languages and Systems, 9th European Symposium on Programming, ESOP 2000, Held as Part of the European Joint Conferences on the Theory and Practice of Software, ETAPS 2000, Berlin, Germany, March 25 - April 2, 2000, Proceedings, Gert Smolka (Ed.) (Lecture Notes in Computer Science, Vol. 1782). Springer, 366–381. https://doi.org/10.1007/3-540-46425-5_24
Google Scholar
Cross Ref
- Arnaud Spiwack, Csongor Kiss, Jean-Philippe Bernardy, Nicolas Wu, and Richard A. Eisenberg. 2021. Linear Constraints. CoRR, abs/2103.06127 (2021), arXiv:2103.06127. arxiv:2103.06127
Google Scholar
- Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with Type Equality Coercions. In Proceedings of the 2007 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation (TLDI ’07). Association for Computing Machinery, New York, NY, USA. 53–66. isbn:159593393X https://doi.org/10.1145/1190315.1190324
Google Scholar
Digital Library
- Dimitrios Vytiniotis, Simon Peyton Jones, and Tom Schrijvers. 2010. Let Should Not Be Generalized. In Proceedings of the 5th ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI ’10). Association for Computing Machinery, New York, NY, USA. 39–50. isbn:9781605588919 https://doi.org/10.1145/1708016.1708023
Google Scholar
Digital Library
- Dimitrios Vytiniotis, Simon Peyton Jones, Tom Schrijvers, and Martin Sulzmann. 2011. OutsideIn(X) Modular type inference with local assumptions. Journal of Functional Programming, 21, 4-5 (2011), 333–412. https://doi.org/10.1017/S0956796811000098
Google Scholar
Digital Library
- David Walker and J. Gregory Morrisett. 2000. Alias Types for Recursive Data Structures. In Types in Compilation, Third International Workshop, TIC 2000, Montreal, Canada, September 21, 2000, Revised Selected Papers, Robert Harper (Ed.) (Lecture Notes in Computer Science, Vol. 2071). Springer, 177–206. https://doi.org/10.1007/3-540-45332-6_7
Google Scholar
Cross Ref
- Stephanie Weirich, Antoine Voizard, Pedro Henrique Azevedo de Amorim, and Richard A. Eisenberg. 2017. A Specification for Dependent Types in Haskell. Proc. ACM Program. Lang., 1, ICFP (2017), Article 31, Aug., 29 pages. https://doi.org/10.1145/3110275
Google Scholar
Digital Library
- Dengping Zhu and Hongwei Xi. 2005. Safe Programming with Pointers Through Stateful Views. In Practical Aspects of Declarative Languages, Manuel V. Hermenegildo and Daniel Cabeza (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 83–97. isbn:978-3-540-30557-6
Google Scholar
Index Terms
Linearly qualified types: generic inference for capabilities and uniqueness
Recommendations
Linear Haskell: practical linearity in a higher-order polymorphic language
Linear type systems have a long and storied history, but not a clear path forward to integrate with existing languages such as OCaml or Haskell. In this paper, we study a linear type system designed with two crucial properties in mind: backwards-...
Qualified types for MLF
ICFP '05: Proceedings of the tenth ACM SIGPLAN international conference on Functional programmingMLF is a type system that extends a functional language with impredicative rank-n polymorphism. Type inference remains possible and only in some clearly defined situations, a local type annotation is required. Qualified types are a general concept that ...
Qualified types for MLF
Proceedings of the tenth ACM SIGPLAN international conference on Functional programmingMLF is a type system that extends a functional language with impredicative rank-n polymorphism. Type inference remains possible and only in some clearly defined situations, a local type annotation is required. Qualified types are a general concept that ...






Comments