Container Unification
Folkert de Vries, Sven-Bodo Scholz, Sjaak Smeters
september 2020
for uniqueness types
Uniqueness Types
Track in the
type
that a value has just one pointer to it
at runtime
System 1: Clean
System 2: UTS
- defined on the lambda calculus
- easier to add advanced type system features
Uniqueness
unique
exactly 1 reference
non-unique
many references
Identity
Duplicate
Uniqueness Relations
non-unique container
unique
element
UTS
idea: use logic expressions to encode relations
UTS
idea: use logic expressions to encode relations
My Problem
Boolean Unification
idea: when are two formulae equivalent?
finds the (most-general) unifier
Boolean Unification
claim: not a good fit in practice
😕
Toward Solutions
faster unification of uniqueness attributes
🚀
Disjunctions are for Containers
There is a hierarchy between variables
- \(u, v\) are lower bounds
- define \( w \) as an upper bound
- \(w\) dominates \(u\) and \(v\)
There is a hierarchy between variables
Disjunction & Unique
we don't know which variable will be \(\bullet\), therefore have to keep all options available in the unifier
Disjunction & Unique
Disjunction & Disjunction
- unify dominators
- accumulate dominated
Polymorphic records
unifies to:
"at least field \(name\) and at least field \(age\)"
A Polymorphic Type System for Extensible Records and Variants (Gaster & Jones, 1996)
Container Annotation
Record-Inspired Unification
Container Unification
rules
Swap
with container unification
Conclusion
- introduce hierarchy
- steal unification trick from records
IFL
By folkert de vries
IFL
- 45