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.
Supplemental Material
- Kenichi Asai and Yukiyoshi Kameyama. 2007. Polymorphic delimited continuations. In Asian Symposium on Programming Languages and Systems.Google Scholar
Cross Ref
- Franz Baader. 1998. On the complexity of Boolean unification. Inform. Process. Lett. ( 1998 ).Google Scholar
- Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. Journal of logical and algebraic methods in programming ( 2015 ).Google Scholar
- Alexander Bockmayr. 1991. Logic Programming with Pseudo-Boolean Constraints. ( 1991 ).Google Scholar
- George Boole. 1847. The mathematical analysis of logic.Google Scholar
- 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 Google Scholar
Digital Library
- 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 ).Google Scholar
- Edwin Brady. 2013. Programming and reasoning with algebraic efects and dependent types. In Proc. International Conference on Functional Programming (ICFP).Google Scholar
- Wolfram Buttner and Helmut Simonis. 1987. Embedding Boolean expressions into logic programming. Journal of Symbolic Computation ( 1987 ).Google Scholar
- Luis Damas. 1984. Type assignment in programming languages. Ph.D. Dissertation. The University of Edinburgh.Google Scholar
- Olivier Danvy and Andrzej Filinski. 1990. Abstracting control. In Proc. Conference on LISP and Functional Programming.Google Scholar
Digital Library
- Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Efective concurrency through algebraic efects. In The OCaml Workshop.Google Scholar
- Jacques Garrigue. 2004. Relaxing the value restriction. In International Symposium on Functional and Logic Programming.Google Scholar
Cross Ref
- Roger Hindley. 1969. The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society (AMS) ( 1969 ).Google Scholar
- Mark P Jones. 2003. Qualified types: theory and practice. Cambridge University Press.Google Scholar
- 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.Google Scholar
- Oleg Kiselyov and KC Sivaramakrishnan. 2018. Ef directly in OCaml. arXiv preprint arXiv: 1812. 11664 ( 2018 ).Google Scholar
- Daan Leijen. 2005. Extensible records with scoped labels. Trends in Functional Programming (TFP) ( 2005 ).Google Scholar
- Daan Leijen. 2014. Koka: Programming with row polymorphic efect types. Workshop on Mathematically Structured Functional Programming (MSFP) ( 2014 ).Google Scholar
Cross Ref
- Daan Leijen. 2017. Type directed compilation of row-typed algebraic efects. In Proc. Symposium on Principles of Programming Languages (POPL).Google Scholar
- Xavier Leroy and François Pessaux. 2000. Type-based analysis of uncaught exceptions. ACM Transactions on Programming Languages and Systems (TOPLAS) ( 2000 ).Google Scholar
- Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do Be Do Be Do. In Proc. Principles of Programming Languages (POPL).Google Scholar
Digital Library
- Leopold Löwenheim. 1908. Über das Auflösungsproblem im logischen Klassenkalkul.Google Scholar
- John M Lucassen and David K Giford. 1988. Polymorphic efect systems. In Proc. Principles of Programming Languages (POPL).Google Scholar
- Enrico Macii, Giuseppe Odasso, and Massimo Poncino. 1998. Comparing diferent Boolean unification algorithms. In Proc. Asilomar Conference on Signals, Systems and Computer.Google Scholar
- 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).Google Scholar
Digital Library
- 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 ).Google Scholar
Digital Library
- 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).Google Scholar
Digital Library
- Harry G. Mairson. 1990. Deciding ML Typability is Complete for Deterministic Exponential Time. In Proc. Principles of Programming Languages (POPL).Google Scholar
Digital Library
- Alberto Martelli and Ugo Montanari. 1982. An eficient unification algorithm. ACM Transactions on Programming Languages and Systems (TOPLAS) ( 1982 ).Google Scholar
- Urusula Martin and Tobias Nipkow. 1989. Boolean Unification-The Story So Far. Journal of Symbolic Computation ( 1989 ).Google Scholar
- Robin Milner. 1978. A theory of type polymorphism in programming. J. Comput. System Sci. ( 1978 ).Google Scholar
- Gordon Plotkin and Matija Pretnar. 2009. Handlers of algebraic efects. In European Symposium on Programming (ESOP).Google Scholar
- Sergiu Rudeanu. 1974. Boolean functions and equations.Google Scholar
- Lukas Rytz, Martin Odersky, and Philipp Haller. 2012. Lightweight polymorphic efects. In Proc. European Conference on Object-Oriented Programming (ECOOP).Google Scholar
- Philipp Schuster, Jonathan Immanuel Brachthäuser, and Klaus Ostermann. 2020. Compiling efect handlers in capabilitypassing style. Proc. International Conference on Functional Programming (ICFP) ( 2020 ).Google Scholar
- 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.Google Scholar
- Jean-Pierre Talpin and Pierre Jouvelot. 1994. The type and efect discipline. Information and Computation ( 1994 ).Google Scholar
- Mads Tofte. 1990. Type inference for polymorphic references. Information and Computation ( 1990 ).Google Scholar
- Mads Tofte and Jean-Pierre Talpin. 1997. Region-based memory management. Information and Computation ( 1997 ).Google Scholar
- Matías Toro and Éric Tanter. 2015. Customizable gradual polymorphic efects for Scala. Proc. Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA) ( 2015 ).Google Scholar
- Dimitrios Vytiniotis, Simon Peyton Jones, and Tom Schrijvers. 2010. Let should not be generalized. In Proc. Workshop on Types in Language Design and Implementation.Google Scholar
Digital Library
- Philip Wadler and Stephen Blott. 1989. How to make ad-hoc polymorphism less ad hoc. In Proc. Symposium on Principles of Programming Languages (POPL).Google Scholar
Digital Library
- Andrew K Wright. 1995. Simple imperative polymorphism. Lisp and Symbolic Computation ( 1995 ).Google Scholar
- Andrew K Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Information and Computation ( 1994 ).Google Scholar
- Yichen Xie and Dawson Engler. 2002. Using redundancies to find errors. In Proc. Symposium on Foundations of Software Engineering (FSE).Google Scholar
Digital Library
Index Terms
Polymorphic types and effects with Boolean unification
Recommendations
Relational nullable types with Boolean unification
We present a simple, practical, and expressive relational nullable type system. A relational nullable type system captures whether an expression may evaluate to null based on its type, but also based on the type of other related expressions. The type ...
Polymorphic type inference and abstract data types
Many statically typed programming languages provide an abstract data type construct, such as the module in Modula-2. However, in most of these languages, implementations of abstract data types are not first-class values. Thus, they cannot be assigned to ...
Type checking and inference for polymorphic and existential types
CATS '09: Proceedings of the Fifteenth Australasian Symposium on Computing: The Australasian Theory - Volume 94This paper proves undecidability of type checking and type inference problems in some variants of typed lambda calculi with polymorphic and existential types. First, type inference in the domain-free polymorphic lambda calculus is proved to be ...






Comments