blob: b3031fcfbfdca2aee74425e3f131dd1673bd3331 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
type attributes = BatSet.String.t
type mode = {bound: attributes; yields: Cardinality.t}
type t = mode list
let mode bound yields = {bound= BatSet.String.of_list bound; yields}
let generation modes bound =
List.fold_left
(fun tightest {bound= declared; yields} ->
if BatSet.String.subset declared bound then
Some (Option.fold ~none:yields ~some:(Cardinality.meet yields) tightest)
else tightest )
None modes
let exhaustible modes bound =
Option.fold ~none:false ~some:Cardinality.exhaustible (generation modes bound)
let project attributes = List.filter (fun {bound; _} -> BatSet.String.subset bound attributes)
let given attributes =
List.map (fun {bound; yields} -> {bound= BatSet.String.diff bound attributes; yields})
|