aboutsummaryrefslogtreecommitdiff
path: root/lib/dyn.mli
blob: c94fa764badd59775176a877a99b321c3e2c1b46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

(** Dynamics. Use with extreme care. Not for kids. *)
module type TParam =
sig
  type 'a t
end

module type S =
sig
type 'a tag
type t = Dyn : 'a tag * 'a -> t

val create : string -> 'a tag
val eq : 'a tag -> 'b tag -> ('a, 'b) CSig.eq option
val repr : 'a tag -> string

type any = Any : 'a tag -> any

val name : string -> any option

module Map(M : TParam) :
sig
  type t
  val empty : t
  val add : 'a tag -> 'a M.t -> t -> t
  val remove : 'a tag -> t -> t
  val find : 'a tag -> t -> 'a M.t
  val mem : 'a tag -> t -> bool

  type any = Any : 'a tag * 'a M.t -> any

  type map = { map : 'a. 'a tag -> 'a M.t -> 'a M.t }
  val map : map -> t -> t

  val iter : (any -> unit) -> t -> unit
  val fold : (any -> 'r -> 'r) -> t -> 'r -> 'r

end

val dump : unit -> (int * string) list

end

(** FIXME: use OCaml 4.02 generative functors when available *)
module Make(M : CSig.EmptyS) : S