diff options
Diffstat (limited to 'lib/concepts')
| -rw-r--r-- | lib/concepts/Mode.ml | 17 | ||||
| -rw-r--r-- | lib/concepts/Mode.mli | 3 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/concepts/Mode.ml b/lib/concepts/Mode.ml index 23abacf..6ac1704 100644 --- a/lib/concepts/Mode.ml +++ b/lib/concepts/Mode.ml @@ -21,15 +21,16 @@ let generation declaration bound = (fun tightest {bound= declared; affords} -> match affords with | Generates cardinality when BatSet.String.subset declared bound -> - Some - ( match tightest with - | None -> cardinality - | Some other -> Cardinality.meet cardinality other ) + Some (Option.fold ~none:cardinality ~some:(Cardinality.meet cardinality) tightest) | Generates _ | Decides -> tightest ) None declaration +let exhaustible declaration bound = + Option.fold ~none:false ~some:Cardinality.exhaustible (generation declaration bound) + let decision declaration bound = - List.exists - (fun {bound= declared; affords} -> - match affords with Decides -> BatSet.String.equal declared bound | Generates _ -> false ) - declaration + exhaustible declaration bound + || List.exists + (fun {bound= declared; affords} -> + match affords with Decides -> BatSet.String.equal declared bound | Generates _ -> false ) + declaration diff --git a/lib/concepts/Mode.mli b/lib/concepts/Mode.mli index 982518a..8d84093 100644 --- a/lib/concepts/Mode.mli +++ b/lib/concepts/Mode.mli @@ -24,4 +24,7 @@ val to_list : t -> mode list attributes left free are then fewer and no more numerous. *) val generation : t -> attributes -> Cardinality.t option +val exhaustible : t -> attributes -> bool + +(** declared outright, or implied by a generation that can be exhausted. *) val decision : t -> attributes -> bool |
