skip to main content
research-article
Open Access

Polymorphic types and effects with Boolean unification

Published:13 November 2020Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

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.Google ScholarGoogle ScholarCross RefCross Ref
  2. Franz Baader. 1998. On the complexity of Boolean unification. Inform. Process. Lett. ( 1998 ).Google ScholarGoogle Scholar
  3. Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. Journal of logical and algebraic methods in programming ( 2015 ).Google ScholarGoogle Scholar
  4. Alexander Bockmayr. 1991. Logic Programming with Pseudo-Boolean Constraints. ( 1991 ).Google ScholarGoogle Scholar
  5. George Boole. 1847. The mathematical analysis of logic.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 ).Google ScholarGoogle Scholar
  8. Edwin Brady. 2013. Programming and reasoning with algebraic efects and dependent types. In Proc. International Conference on Functional Programming (ICFP).Google ScholarGoogle Scholar
  9. Wolfram Buttner and Helmut Simonis. 1987. Embedding Boolean expressions into logic programming. Journal of Symbolic Computation ( 1987 ).Google ScholarGoogle Scholar
  10. Luis Damas. 1984. Type assignment in programming languages. Ph.D. Dissertation. The University of Edinburgh.Google ScholarGoogle Scholar
  11. Olivier Danvy and Andrzej Filinski. 1990. Abstracting control. In Proc. Conference on LISP and Functional Programming.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Efective concurrency through algebraic efects. In The OCaml Workshop.Google ScholarGoogle Scholar
  13. Jacques Garrigue. 2004. Relaxing the value restriction. In International Symposium on Functional and Logic Programming.Google ScholarGoogle ScholarCross RefCross Ref
  14. Roger Hindley. 1969. The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society (AMS) ( 1969 ).Google ScholarGoogle Scholar
  15. Mark P Jones. 2003. Qualified types: theory and practice. Cambridge University Press.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  17. Oleg Kiselyov and KC Sivaramakrishnan. 2018. Ef directly in OCaml. arXiv preprint arXiv: 1812. 11664 ( 2018 ).Google ScholarGoogle Scholar
  18. Daan Leijen. 2005. Extensible records with scoped labels. Trends in Functional Programming (TFP) ( 2005 ).Google ScholarGoogle Scholar
  19. Daan Leijen. 2014. Koka: Programming with row polymorphic efect types. Workshop on Mathematically Structured Functional Programming (MSFP) ( 2014 ).Google ScholarGoogle ScholarCross RefCross Ref
  20. Daan Leijen. 2017. Type directed compilation of row-typed algebraic efects. In Proc. Symposium on Principles of Programming Languages (POPL).Google ScholarGoogle Scholar
  21. Xavier Leroy and François Pessaux. 2000. Type-based analysis of uncaught exceptions. ACM Transactions on Programming Languages and Systems (TOPLAS) ( 2000 ).Google ScholarGoogle Scholar
  22. Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do Be Do Be Do. In Proc. Principles of Programming Languages (POPL).Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Leopold Löwenheim. 1908. Über das Auflösungsproblem im logischen Klassenkalkul.Google ScholarGoogle Scholar
  24. John M Lucassen and David K Giford. 1988. Polymorphic efect systems. In Proc. Principles of Programming Languages (POPL).Google ScholarGoogle Scholar
  25. Enrico Macii, Giuseppe Odasso, and Massimo Poncino. 1998. Comparing diferent Boolean unification algorithms. In Proc. Asilomar Conference on Signals, Systems and Computer.Google ScholarGoogle Scholar
  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).Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 ).Google ScholarGoogle ScholarDigital LibraryDigital Library
  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).Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Harry G. Mairson. 1990. Deciding ML Typability is Complete for Deterministic Exponential Time. In Proc. Principles of Programming Languages (POPL).Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Alberto Martelli and Ugo Montanari. 1982. An eficient unification algorithm. ACM Transactions on Programming Languages and Systems (TOPLAS) ( 1982 ).Google ScholarGoogle Scholar
  31. Urusula Martin and Tobias Nipkow. 1989. Boolean Unification-The Story So Far. Journal of Symbolic Computation ( 1989 ).Google ScholarGoogle Scholar
  32. Robin Milner. 1978. A theory of type polymorphism in programming. J. Comput. System Sci. ( 1978 ).Google ScholarGoogle Scholar
  33. Gordon Plotkin and Matija Pretnar. 2009. Handlers of algebraic efects. In European Symposium on Programming (ESOP).Google ScholarGoogle Scholar
  34. Sergiu Rudeanu. 1974. Boolean functions and equations.Google ScholarGoogle Scholar
  35. Lukas Rytz, Martin Odersky, and Philipp Haller. 2012. Lightweight polymorphic efects. In Proc. European Conference on Object-Oriented Programming (ECOOP).Google ScholarGoogle Scholar
  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 ).Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  38. Jean-Pierre Talpin and Pierre Jouvelot. 1994. The type and efect discipline. Information and Computation ( 1994 ).Google ScholarGoogle Scholar
  39. Mads Tofte. 1990. Type inference for polymorphic references. Information and Computation ( 1990 ).Google ScholarGoogle Scholar
  40. Mads Tofte and Jean-Pierre Talpin. 1997. Region-based memory management. Information and Computation ( 1997 ).Google ScholarGoogle Scholar
  41. Matías Toro and Éric Tanter. 2015. Customizable gradual polymorphic efects for Scala. Proc. Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA) ( 2015 ).Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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).Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Andrew K Wright. 1995. Simple imperative polymorphism. Lisp and Symbolic Computation ( 1995 ).Google ScholarGoogle Scholar
  45. Andrew K Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Information and Computation ( 1994 ).Google ScholarGoogle Scholar
  46. Yichen Xie and Dawson Engler. 2002. Using redundancies to find errors. In Proc. Symposium on Foundations of Software Engineering (FSE).Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Polymorphic types and effects with Boolean unification

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!