Fast and Efficient Boolean Unification for Hindley-Milner-Style Type and Effect Systems

Research output: Contribution to journalJournal articleResearchpeer-review


  • Fulltext

    Final published version, 630 KB, PDF document

As type and effect systems become more expressive there is an increasing need for efficient type inference. We consider a polymorphic effect system based on Boolean formulas where inference requires Boolean unification. Since Boolean unification involves semantic equivalence, conventional syntax-driven unification is insufficient. At the same time, existing Boolean unification techniques are ill-suited for type inference. We propose a hybrid algorithm for solving Boolean unification queries based on Boole's Successive Variable Elimination (SVE) algorithm. The proposed approach builds on several key observations regarding the Boolean unification queries encountered in practice, including: (i) most queries are simple, (ii) most queries involve a few flexible variables, (iii) queries are likely to repeat due similar programming patterns, and (iv) there is a long tail of complex queries. We exploit these observations to implement several strategies for formula minimization, including ones based on tabling and binary decision diagrams. We implement the new hybrid approach in the Flix programming language. Experimental results show that by reducing the overhead of Boolean unification, the compilation throughput increases from 8,580 lines/sec to 15,917 lines/sec corresponding to a 1.8x speed-up. Further, the overhead on type and effect inference time is only 16% which corresponds to an overhead of less than 7% on total compilation time. We study the hybrid approach and demonstrate that each design choice improves performance.

Original languageEnglish
Article number240
JournalProceedings of the ACM on Programming Languages
Issue numberOOPSLA2
Number of pages29
Publication statusPublished - 2023

Bibliographical note

Publisher Copyright:
© 2023 Owner/Author.

    Research areas

  • Boolean unification, Hindley-Milner type systems, type inference

ID: 390399735