···11+22+* Build depend on topkg.
33+44+v0.8.0 2016-03-08 La Forclaz (VS)
55+---------------------------------
66+77+First release.
+13
vendor/opam/hmap/LICENSE.md
···11+ Copyright (c) 2016 Daniel C. Bünzli
22+33+ Permission to use, copy, modify, and/or distribute this software for any
44+ purpose with or without fee is hereby granted, provided that the above
55+ copyright notice and this permission notice appear in all copies.
66+77+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
88+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
99+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1010+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1111+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1212+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+43
vendor/opam/hmap/README.md
···11+Hmap — Heterogeneous value maps for OCaml
22+-------------------------------------------------------------------------------
33+%%VERSION%%
44+55+Hmap provides heterogeneous value maps for OCaml. These maps bind keys
66+to values with arbitrary types. Keys witness the type of the value
77+they are bound to which allows to add and lookup bindings in a type
88+safe manner.
99+1010+Hmap has no dependency and is distributed under the ISC license.
1111+1212+Home page: http://erratique.ch/software/hmap
1313+Contact: Daniel Bünzli `<daniel.buenzl i@erratique.ch>`
1414+1515+## Installation
1616+1717+Hmap can be installed with `opam`:
1818+1919+ opam install hmap
2020+2121+If you don't use `opam` consult the [`opam`](opam) file for build
2222+instructions.
2323+2424+## Documentation
2525+2626+The documentation and API reference is automatically generated by
2727+`ocamldoc` from the interfaces. It can be consulted [online][doc]
2828+and there is a generated version in the `doc` directory of the
2929+distribution.
3030+3131+[doc]: http://erratique.ch/software/hmap/doc
3232+3333+## Sample programs
3434+3535+If you installed Hmap with `opam` sample programs are located in
3636+the directory `opam config var hmap:doc`.
3737+3838+In the distribution sample programs and tests are located in the
3939+[`test`](test) directory of the distribution. They can be built an run
4040+with
4141+4242+ topkg build --tests true
4343+ topkg test
+4
vendor/opam/hmap/_tags
···11+true : bin_annot, safe_string
22+33+<src> : include
44+<test> : include
···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2016 Daniel C. Bünzli. All rights reserved.
33+ Distributed under the ISC license, see terms at the end of the file.
44+ %%NAME%% %%VERSION%%
55+ ---------------------------------------------------------------------------*)
66+77+(* Type identifiers.
88+ See http://alan.petitepomme.net/cwn/2015.03.24.html#1 *)
99+1010+module Tid = struct type _ t = .. end
1111+module type Tid = sig
1212+ type t
1313+ type _ Tid.t += Tid : t Tid.t
1414+end
1515+1616+type 'a tid = (module Tid with type t = 'a)
1717+1818+let tid () (type s) =
1919+ let module M = struct
2020+ type t = s
2121+ type _ Tid.t += Tid : t Tid.t
2222+ end
2323+ in
2424+ (module M : Tid with type t = s)
2525+2626+type ('a, 'b) teq = Teq : ('a, 'a) teq
2727+2828+let eq : type r s. r tid -> s tid -> (r, s) teq option =
2929+ fun r s ->
3030+ let module R = (val r : Tid with type t = r) in
3131+ let module S = (val s : Tid with type t = s) in
3232+ match R.Tid with
3333+ | S.Tid -> Some Teq
3434+ | _ -> None
3535+3636+(* Heterogeneous maps *)
3737+3838+module type KEY_INFO = sig
3939+ type 'a t
4040+end
4141+4242+module type S = sig
4343+4444+ type 'a key
4545+4646+ module Key : sig
4747+ type 'a info
4848+ val create : 'a info -> 'a key
4949+ val info : 'a key -> 'a info
5050+5151+ type t
5252+ val hide_type : 'a key -> t
5353+ val equal : t -> t -> bool
5454+ val compare : t -> t -> int
5555+ end
5656+5757+ type t
5858+ val empty : t
5959+ val is_empty : t -> bool
6060+ val mem : 'a key -> t -> bool
6161+ val add : 'a key -> 'a -> t -> t
6262+ val singleton : 'a key -> 'a -> t
6363+ val rem : 'a key -> t -> t
6464+ val find : 'a key -> t -> 'a option
6565+ val get : 'a key -> t -> 'a
6666+6767+ type binding = B : 'a key * 'a -> binding
6868+ val iter : (binding -> unit) -> t -> unit
6969+ val fold : (binding -> 'a -> 'a) -> t -> 'a -> 'a
7070+ val for_all : (binding -> bool) -> t -> bool
7171+ val exists : (binding -> bool) -> t -> bool
7272+ val filter : (binding -> bool) -> t -> t
7373+ val cardinal : t -> int
7474+ val any_binding : t -> binding option
7575+ val get_any_binding : t -> binding
7676+end
7777+7878+7979+module Make (Key_info : KEY_INFO) : S
8080+with type 'a Key.info = 'a Key_info.t = struct
8181+8282+ (* Keys *)
8383+8484+ module Key = struct
8585+8686+ type 'a info = 'a Key_info.t
8787+ type 'a key = { uid : int; tid : 'a tid; info : 'a Key_info.t }
8888+8989+ let uid =
9090+ let id = ref (-1) in
9191+ fun () -> incr id; !id
9292+9393+ let create info =
9494+ let uid = uid () in
9595+ let tid = tid () in
9696+ { uid; tid; info }
9797+9898+ let info k = k.info
9999+100100+ type t = V : 'a key -> t
101101+ let hide_type k = V k
102102+ let equal (V k0) (V k1) = (compare : int -> int -> int) k0.uid k1.uid = 0
103103+ let compare (V k0) (V k1) = (compare : int -> int -> int) k0.uid k1.uid
104104+ end
105105+106106+ type 'a key = 'a Key.key
107107+108108+ (* Maps *)
109109+110110+ module M = Map.Make (Key)
111111+ type binding = B : 'a key * 'a -> binding
112112+ type t = binding M.t
113113+114114+ let empty = M.empty
115115+ let is_empty = M.is_empty
116116+ let mem k m = M.mem (Key.V k) m
117117+ let add k v m = M.add (Key.V k) (B (k, v)) m
118118+ let singleton k v = M.singleton (Key.V k) (B (k, v))
119119+ let rem k m = M.remove (Key.V k) m
120120+ let find : type a. a key -> t -> a option =
121121+ fun k s ->
122122+ try match M.find (Key.V k) s with
123123+ | B (k', v) ->
124124+ match eq k.Key.tid k'.Key.tid with
125125+ | None -> None
126126+ | Some Teq -> Some v
127127+ with Not_found -> None
128128+129129+ let get k s = match find k s with
130130+ | None -> invalid_arg "key not found in map"
131131+ | Some v -> v
132132+133133+ let iter f m = M.iter (fun _ b -> f b) m
134134+ let fold f m acc = M.fold (fun _ b acc -> f b acc) m acc
135135+ let for_all p m = M.for_all (fun _ b -> p b) m
136136+ let exists p m = M.exists (fun _ b -> p b) m
137137+ let filter p m = M.filter (fun _ b -> p b) m
138138+ let cardinal m = M.cardinal m
139139+ let any_binding m = try Some (snd (M.choose m)) with
140140+ | Not_found -> None
141141+142142+ let get_any_binding m = try snd (M.choose m) with
143143+ | Not_found -> invalid_arg "empty map"
144144+end
145145+146146+include Make (struct type 'a t = unit end)
147147+148148+(*---------------------------------------------------------------------------
149149+ Copyright (c) 2016 Daniel C. Bünzli
150150+151151+ Permission to use, copy, modify, and/or distribute this software for any
152152+ purpose with or without fee is hereby granted, provided that the above
153153+ copyright notice and this permission notice appear in all copies.
154154+155155+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
156156+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
157157+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
158158+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
159159+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
160160+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
161161+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
162162+ ---------------------------------------------------------------------------*)
+237
vendor/opam/hmap/src/hmap.mli
···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2016 Daniel C. Bünzli. All rights reserved.
33+ Distributed under the ISC license, see terms at the end of the file.
44+ %%NAME%% %%VERSION%%
55+ ---------------------------------------------------------------------------*)
66+77+(** Heterogeneous value maps.
88+99+ {e %%VERSION%% - {{:%%PKG_HOMEPAGE%% }homepage}} *)
1010+1111+(** {1:keys Keys} *)
1212+1313+type 'a key
1414+(** The type for keys whose lookup value is of type ['a]. *)
1515+1616+(** Keys. *)
1717+module Key : sig
1818+1919+ (** {1:keys Keys} *)
2020+2121+ val create : unit -> 'a key
2222+ (** [create ()] is a new key. *)
2323+2424+ (** {1:exists Existential keys}
2525+2626+ Exisential keys allows to compare keys. This can be useful for functions
2727+ like {!filter}. *)
2828+2929+ type t
3030+ (** The type for existential keys. *)
3131+3232+ val hide_type : 'a key -> t
3333+ (** [hide_type k] is an existential key for [k]. *)
3434+3535+ val equal : t -> t -> bool
3636+ (** [equal k k'] is [true] iff [k] and [k'] are the same key. *)
3737+3838+ val compare : t -> t -> int
3939+ (** [compare k k'] is a total order on keys compatible with {!equal}. *)
4040+end
4141+4242+(** {1:maps Maps} *)
4343+4444+type t
4545+(** The type for heterogeneous value maps. *)
4646+4747+val empty : t
4848+(** [empty] is the empty map. *)
4949+5050+val is_empty : t -> bool
5151+(** [is_empty m] is [true] iff [m] is empty. *)
5252+5353+val mem : 'a key -> t -> bool
5454+(** [mem k m] is [true] iff [k] is bound in [m]. *)
5555+5656+val add : 'a key -> 'a -> t -> t
5757+(** [add k v m] is [m] with [k] bound to [v]. *)
5858+5959+val singleton : 'a key -> 'a -> t
6060+(** [singleton k v] is [add k v empty]. *)
6161+6262+val rem : 'a key -> t -> t
6363+(** [rem k m] is [m] with [k] unbound. *)
6464+6565+val find : 'a key -> t -> 'a option
6666+(** [find k m] is the value of [k]'s binding in [m], if any. *)
6767+6868+val get : 'a key -> t -> 'a
6969+(** [get k m] is the value of [k]'s binding in [m].
7070+7171+ @raise Invalid_argument if [k] is not bound in [m]. *)
7272+7373+(** The type for bindings. *)
7474+type binding = B : 'a key * 'a -> binding
7575+7676+val iter : (binding -> unit) -> t -> unit
7777+(** [iter f m] applies [f] to all bindings of [m]. *)
7878+7979+val fold : (binding -> 'a -> 'a) -> t -> 'a -> 'a
8080+(** [fold f m acc] folds over the bindings of [m] with [f], starting with
8181+ [acc] *)
8282+8383+val for_all : (binding -> bool) -> t -> bool
8484+(** [for_all p m] is [true] iff all bindings of [m] satisfy [p]. *)
8585+8686+val exists : (binding -> bool) -> t -> bool
8787+(** [exists p m] is [true] iff there exists a bindings of [m] that
8888+ satisfies [p]. *)
8989+9090+val filter : (binding -> bool) -> t -> t
9191+(** [filter p m] are the bindings of [m] that satisfy [p]. *)
9292+9393+val cardinal : t -> int
9494+(** [cardinal m] is the number of bindings in [m]. *)
9595+9696+val any_binding : t -> binding option
9797+(** [any_binding m] is a binding of [m] (if not empty). *)
9898+9999+val get_any_binding : t -> binding
100100+(** [get_any_binding m] is a binding of [m].
101101+102102+ @raise Invalid_argument if [m] is empty. *)
103103+104104+(** {1:func Functorial interface}
105105+106106+ The functorial interface allows to associate more information to the
107107+ keys. For example a key name or a key value pretty-printer. *)
108108+109109+(** The type for key information. *)
110110+module type KEY_INFO = sig
111111+ type 'a t
112112+ (** The type for key information. *)
113113+end
114114+115115+(** Output signature of the functor {!Make} *)
116116+module type S = sig
117117+118118+ (** {1:keys Keys} *)
119119+120120+ type 'a key
121121+ (** The type for keys whose lookup value is of type ['a]. *)
122122+123123+ (** Keys. *)
124124+ module Key : sig
125125+126126+ (** {1:keys Keys} *)
127127+128128+ type 'a info
129129+ (** The type for key information. *)
130130+131131+ val create : 'a info -> 'a key
132132+ (** [create i] is a new key with information [i]. *)
133133+134134+ val info : 'a key -> 'a info
135135+ (** [info k] is [k]'s information. *)
136136+137137+ (** {1:exists Existential keys}
138138+139139+ Exisential keys allow to compare keys. This can be useful for
140140+ functions like {!filter}. *)
141141+142142+ type t
143143+ (** The type for existential keys. *)
144144+145145+ val hide_type : 'a key -> t
146146+ (** [hide_type k] is an existential key for [k]. *)
147147+148148+ val equal : t -> t -> bool
149149+ (** [equal k k'] is [true] iff [k] and [k'] are the same key. *)
150150+151151+ val compare : t -> t -> int
152152+ (** [compare k k'] is a total order on keys compatible with {!equal}. *)
153153+ end
154154+155155+ (** {1:maps Maps} *)
156156+157157+ type t
158158+ (** The type for heterogeneous value maps. *)
159159+160160+ val empty : t
161161+ (** [empty] is the empty map. *)
162162+163163+ val is_empty : t -> bool
164164+ (** [is_empty m] is [true] iff [m] is empty. *)
165165+166166+ val mem : 'a key -> t -> bool
167167+ (** [mem k m] is [true] iff [k] is bound in [m]. *)
168168+169169+ val add : 'a key -> 'a -> t -> t
170170+ (** [add k v m] is [m] with [k] bound to [v]. *)
171171+172172+ val singleton : 'a key -> 'a -> t
173173+ (** [singleton k v] is [add k v empty]. *)
174174+175175+ val rem : 'a key -> t -> t
176176+ (** [rem k m] is [m] with [k] unbound. *)
177177+178178+ val find : 'a key -> t -> 'a option
179179+ (** [find k m] is the value of [k]'s binding in [m], if any. *)
180180+181181+ val get : 'a key -> t -> 'a
182182+ (** [get k m] is the value of [k]'s binding in [m].
183183+184184+ @raise Invalid_argument if [k] is not bound in [m]. *)
185185+186186+ (** The type for bindings. *)
187187+ type binding = B : 'a key * 'a -> binding
188188+189189+ val iter : (binding -> unit) -> t -> unit
190190+ (** [iter f m] applies [f] to all bindings of [m]. *)
191191+192192+ val fold : (binding -> 'a -> 'a) -> t -> 'a -> 'a
193193+ (** [fold f m acc] folds over the bindings of [m] with [f], starting with
194194+ [acc] *)
195195+196196+ val for_all : (binding -> bool) -> t -> bool
197197+ (** [for_all p m] is [true] iff all bindings of [m] satisfy [p]. *)
198198+199199+ val exists : (binding -> bool) -> t -> bool
200200+ (** [exists p m] is [true] iff there exists a bindings of [m] that
201201+ satisfies [p]. *)
202202+203203+ val filter : (binding -> bool) -> t -> t
204204+ (** [filter p m] are the bindings of [m] that satisfy [p]. *)
205205+206206+ val cardinal : t -> int
207207+ (** [cardinal m] is the number of bindings in [m]. *)
208208+209209+ val any_binding : t -> binding option
210210+ (** [any_binding m] is a binding of [m] (if not empty). *)
211211+212212+ val get_any_binding : t -> binding
213213+ (** [get_any_binding m] is a binding of [m].
214214+215215+ @raise Invalid_argument if [m] is empty. *)
216216+end
217217+218218+(** Functor for heterogeneous maps whose keys hold information
219219+ of type [Key_info.t] *)
220220+module Make :
221221+ functor (Key_info : KEY_INFO) -> S with type 'a Key.info = 'a Key_info.t
222222+223223+(*---------------------------------------------------------------------------
224224+ Copyright (c) 2016 Daniel C. Bünzli
225225+226226+ Permission to use, copy, modify, and/or distribute this software for any
227227+ purpose with or without fee is hereby granted, provided that the above
228228+ copyright notice and this permission notice appear in all copies.
229229+230230+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
231231+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
232232+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
233233+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
234234+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
235235+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
236236+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
237237+ ---------------------------------------------------------------------------*)
···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2016 Daniel C. Bünzli. All rights reserved.
33+ Distributed under the ISC license, see terms at the end of the file.
44+ %%NAME%% %%VERSION%%
55+ ---------------------------------------------------------------------------*)
66+77+let test () =
88+ let ik = Hmap.Key.create () in
99+ let sk = Hmap.Key.create () in
1010+ let uk = Hmap.Key.create () in
1111+ let m = Hmap.(empty |> add ik 5 |> add sk "hey") in
1212+ assert (Hmap.mem ik m);
1313+ assert (Hmap.mem sk m);
1414+ assert (not (Hmap.mem uk m));
1515+ assert (Hmap.find ik m = Some 5);
1616+ assert (Hmap.get ik m = 5);
1717+ assert (Hmap.find sk m = Some "hey");
1818+ assert (Hmap.get sk m = "hey");
1919+ assert (Hmap.find uk m = None);
2020+ assert (try Hmap.get uk m; false with Invalid_argument _ -> true);
2121+ Printf.printf "Success!\n%!";
2222+ ()
2323+2424+let () = test ()
2525+2626+(*---------------------------------------------------------------------------
2727+ Copyright (c) 2016 Daniel C. Bünzli
2828+2929+ Permission to use, copy, modify, and/or distribute this software for any
3030+ purpose with or without fee is hereby granted, provided that the above
3131+ copyright notice and this permission notice appear in all copies.
3232+3333+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3434+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3535+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3636+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3737+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3838+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3939+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4040+ ---------------------------------------------------------------------------*)