Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Polymorphic types and effects with Boolean unification

Published: 13 November 2020 Publication History

Abstract

We present a simple, practical, and expressive type and effect system based on Boolean constraints. The effect system extends the Hindley-Milner type system, supports parametric polymorphism, and preserves principal types modulo Boolean equivalence. We show how to support type inference by extending Algorithm W with Boolean unification based on the successive variable elimination algorithm.
We implement the type and effect system in the Flix programming language. We perform an in-depth evaluation on the impact of Boolean unification on type inference time and end-to-end compilation time. While the computational complexity of Boolean unification is NP-hard, the experimental results demonstrate that it works well in practice. We find that the impact on type inference time is on average a 1.4x slowdown and the overall impact on end-to-end compilation time is a 1.1x slowdown.

Supplementary Material

Auxiliary Presentation Video (oopsla20main-p97-p-video.mp4)
Presentation of "Polymorphic Types and Effects with Boolean Unification"

References

[1]
Kenichi Asai and Yukiyoshi Kameyama. 2007. Polymorphic delimited continuations. In Asian Symposium on Programming Languages and Systems.
[2]
Franz Baader. 1998. On the complexity of Boolean unification. Inform. Process. Lett. ( 1998 ).
[3]
Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. Journal of logical and algebraic methods in programming ( 2015 ).
[4]
Alexander Bockmayr. 1991. Logic Programming with Pseudo-Boolean Constraints. ( 1991 ).
[5]
George Boole. 1847. The mathematical analysis of logic.
[6]
Alexandre Boudet, Jean-Pierre Jouannaud, and Manfred Schmidt-Schauß. 1989. Unification in Boolean Rings and Abelian Groups. Journal of Symbolic Computation ( 1989 ). https://doi.org/10.1016/S0747-7171 ( 89 ) 80054-9
[7]
Jonathan Immanuel Brachthäuser, Philipp Schuster, and Klaus Ostermann. 2020. Efekt: Capability-passing style for type-and efect-safe, extensible efect handlers in Scala. Journal of Functional Programming ( 2020 ).
[8]
Edwin Brady. 2013. Programming and reasoning with algebraic efects and dependent types. In Proc. International Conference on Functional Programming (ICFP).
[9]
Wolfram Buttner and Helmut Simonis. 1987. Embedding Boolean expressions into logic programming. Journal of Symbolic Computation ( 1987 ).
[10]
Luis Damas. 1984. Type assignment in programming languages. Ph.D. Dissertation. The University of Edinburgh.
[11]
Olivier Danvy and Andrzej Filinski. 1990. Abstracting control. In Proc. Conference on LISP and Functional Programming.
[12]
Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Efective concurrency through algebraic efects. In The OCaml Workshop.
[13]
Jacques Garrigue. 2004. Relaxing the value restriction. In International Symposium on Functional and Logic Programming.
[14]
Roger Hindley. 1969. The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society (AMS) ( 1969 ).
[15]
Mark P Jones. 2003. Qualified types: theory and practice. Cambridge University Press.
[16]
Simon Peyton Jones, Andrew Tolmach, and Tony Hoare. 2001. Playing by the rules: rewriting as a practical optimisation technique in GHC. In The Haskell Workshop.
[17]
Oleg Kiselyov and KC Sivaramakrishnan. 2018. Ef directly in OCaml. arXiv preprint arXiv: 1812. 11664 ( 2018 ).
[18]
Daan Leijen. 2005. Extensible records with scoped labels. Trends in Functional Programming (TFP) ( 2005 ).
[19]
Daan Leijen. 2014. Koka: Programming with row polymorphic efect types. Workshop on Mathematically Structured Functional Programming (MSFP) ( 2014 ).
[20]
Daan Leijen. 2017. Type directed compilation of row-typed algebraic efects. In Proc. Symposium on Principles of Programming Languages (POPL).
[21]
Xavier Leroy and François Pessaux. 2000. Type-based analysis of uncaught exceptions. ACM Transactions on Programming Languages and Systems (TOPLAS) ( 2000 ).
[22]
Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do Be Do Be Do. In Proc. Principles of Programming Languages (POPL).
[23]
Leopold Löwenheim. 1908. Über das Auflösungsproblem im logischen Klassenkalkul.
[24]
John M Lucassen and David K Giford. 1988. Polymorphic efect systems. In Proc. Principles of Programming Languages (POPL).
[25]
Enrico Macii, Giuseppe Odasso, and Massimo Poncino. 1998. Comparing diferent Boolean unification algorithms. In Proc. Asilomar Conference on Signals, Systems and Computer.
[26]
Magnus Madsen and Ondřej Lhoták. 2018. Safe and sound program analysis with Flix. In Proc. International Symposium on Software Testing and Analysis (ISSTA).
[27]
Magnus Madsen and Ondřej Lhoták. 2020. Fixpoints for the Masses: Programming with First-class Datalog Constraints. Proc. ACM Programming Languages Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA) ( 2020 ).
[28]
Magnus Madsen, Ming-Ho Yee, and Ondrej Lhoták. 2016. From Datalog to Flix: a declarative language for fixed points on lattices. In Proc. Programming Language Design and Implementation (PLDI).
[29]
Harry G. Mairson. 1990. Deciding ML Typability is Complete for Deterministic Exponential Time. In Proc. Principles of Programming Languages (POPL).
[30]
Alberto Martelli and Ugo Montanari. 1982. An eficient unification algorithm. ACM Transactions on Programming Languages and Systems (TOPLAS) ( 1982 ).
[31]
Urusula Martin and Tobias Nipkow. 1989. Boolean Unification-The Story So Far. Journal of Symbolic Computation ( 1989 ).
[32]
Robin Milner. 1978. A theory of type polymorphism in programming. J. Comput. System Sci. ( 1978 ).
[33]
Gordon Plotkin and Matija Pretnar. 2009. Handlers of algebraic efects. In European Symposium on Programming (ESOP).
[34]
Sergiu Rudeanu. 1974. Boolean functions and equations.
[35]
Lukas Rytz, Martin Odersky, and Philipp Haller. 2012. Lightweight polymorphic efects. In Proc. European Conference on Object-Oriented Programming (ECOOP).
[36]
Philipp Schuster, Jonathan Immanuel Brachthäuser, and Klaus Ostermann. 2020. Compiling efect handlers in capabilitypassing style. Proc. International Conference on Functional Programming (ICFP) ( 2020 ).
[37]
Helmut Simonis and Mehmet Dincbas. 1987. Using an extended Prolog for digital circuit design. In IEEE International Workshop on AI Applications to CAD Systems for Electronics.
[38]
Jean-Pierre Talpin and Pierre Jouvelot. 1994. The type and efect discipline. Information and Computation ( 1994 ).
[39]
Mads Tofte. 1990. Type inference for polymorphic references. Information and Computation ( 1990 ).
[40]
Mads Tofte and Jean-Pierre Talpin. 1997. Region-based memory management. Information and Computation ( 1997 ).
[41]
Matías Toro and Éric Tanter. 2015. Customizable gradual polymorphic efects for Scala. Proc. Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA) ( 2015 ).
[42]
Dimitrios Vytiniotis, Simon Peyton Jones, and Tom Schrijvers. 2010. Let should not be generalized. In Proc. Workshop on Types in Language Design and Implementation.
[43]
Philip Wadler and Stephen Blott. 1989. How to make ad-hoc polymorphism less ad hoc. In Proc. Symposium on Principles of Programming Languages (POPL).
[44]
Andrew K Wright. 1995. Simple imperative polymorphism. Lisp and Symbolic Computation ( 1995 ).
[45]
Andrew K Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Information and Computation ( 1994 ).
[46]
Yichen Xie and Dawson Engler. 2002. Using redundancies to find errors. In Proc. Symposium on Foundations of Software Engineering (FSE).

Cited By

View all
  • (2024)Associated Effects: Flexible Abstractions for Effectful ProgrammingProceedings of the ACM on Programming Languages10.1145/36563938:PLDI(394-416)Online publication date: 20-Jun-2024
  • (2023)Fast and Efficient Boolean Unification for Hindley-Milner-Style Type and Effect SystemsProceedings of the ACM on Programming Languages10.1145/36228167:OOPSLA2(516-543)Online publication date: 16-Oct-2023
  • (2023)With or Without You: Programming with Effect ExclusionProceedings of the ACM on Programming Languages10.1145/36078467:ICFP(448-475)Online publication date: 30-Aug-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 4, Issue OOPSLA
November 2020
3108 pages
EISSN:2475-1421
DOI:10.1145/3436718
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 13 November 2020
Published in PACMPL Volume 4, Issue OOPSLA

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Boolean unification
  2. polymorphic types and effects
  3. type inference

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)241
  • Downloads (Last 6 weeks)27
Reflects downloads up to 03 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Associated Effects: Flexible Abstractions for Effectful ProgrammingProceedings of the ACM on Programming Languages10.1145/36563938:PLDI(394-416)Online publication date: 20-Jun-2024
  • (2023)Fast and Efficient Boolean Unification for Hindley-Milner-Style Type and Effect SystemsProceedings of the ACM on Programming Languages10.1145/36228167:OOPSLA2(516-543)Online publication date: 16-Oct-2023
  • (2023)With or Without You: Programming with Effect ExclusionProceedings of the ACM on Programming Languages10.1145/36078467:ICFP(448-475)Online publication date: 30-Aug-2023
  • (2022)The Principles of the Flix Programming LanguageProceedings of the 2022 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3563835.3567661(112-127)Online publication date: 29-Nov-2022
  • (2022)Synthesizing Skolem Functions: A View from Theory and PracticeHandbook of Logical Thought in India10.1007/978-81-322-2577-5_51(1187-1222)Online publication date: 5-Nov-2022
  • (2022)Synthesizing Skolem Functions: A View from Theory and PracticeHandbook of Logical Thought in India10.1007/978-81-322-1812-8_51-1(1-36)Online publication date: 1-Jul-2022
  • (2021)Relational nullable types with Boolean unificationProceedings of the ACM on Programming Languages10.1145/34854875:OOPSLA(1-28)Online publication date: 15-Oct-2021

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media