Constraint and Constraint Set Code [blog/lti/cg_def_code]
Constraint and Constraint Set Code [blog/lti/cg_def_code]
struct Constraints(Map[Var, Subtype])
pub fn Constraints::empty() -> Constraints {
Constraints(Map::new())
}
pub fn meet(self : Constraints, other : Constraints) -> Constraints {
union_with(self.inner(), other.inner(), (l, r) => {
let { l: l1, r: r1 } = l
let { l: l2, r: r2 } = r
{ l: l1 & l2, r: r1 | r2 }
})
}
pub fn meets(c : Array[Constraints]) -> Constraints {
c.iter().fold(init=Constraints::empty(), Constraints::meet)
}