Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 46 lines (34 sloc) 1.294 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 module Make (Keys: OrderedTypeSig.S)(Values: OrderedTypeSig.S) :
19 (SetMapSig.S with type key = Keys.t and type elt = Values.t) =
20 struct
21 type key = Keys.t
22 type elt = Values.t
23
24 module M = BaseMap.Make(Keys)
25 module S = BaseSet.Make(Values)
26
27 type t = S.t M.t
28
29 let empty = M.empty
30 let find_opt = M.find_opt
31
32 let find k m =
33 match find_opt k m with
34 | Some s -> s
35 | None -> S.empty
36
37 let add (k:M.key) (v:S.elt) (m:S.t M.t) : S.t M.t =
38 let (set:S.t) = find k m in
39 M.add k (S.add v set) m
40
41 let remove (k:M.key) (v:S.elt) (m:S.t M.t) : S.t M.t =
42 let (set:S.t) = find k m in
43 M.add k (S.remove v set) m
44
45 end
Something went wrong with that request. Please try again.