module Make_tbl: functor (
Key
:
sig
include Hashtbl.HashedType
val to_string : Type.t -> string
end
) ->
functor (
Info
:
sig
end
) ->
Heterogeneous_table
with type key = Key.t and type 'a info = 'a Info.t
Build an heterogeneous table associating keys to info.
Not efficient for types registered without ml name.
Since Carbon-20101201
Parameters: |
Key |
: |
sig include Hashtbl.HashedType val to_string: t -> string end
|
Info |
: |
sig type 'a t end
|
|
type
key
Since Carbon-20101201
type 'a
info
type
t
Type of heterogeneous (hash)tables indexed by values of type Key.t.
Type values ensure type safety.
val create : int -> t
create n
creates a new table of initial size n
.
val add : t ->
key ->
'a Type.ty ->
'a info -> 'a info
add tbl s ty v
binds s
to the value v
in the table tbl
.
If the returned value is a closure whose the type of one of its
argument was dynamically registered, then it may raise
Incompatible_Type
.
Raises AlreadyExists
if s
is already bound in tbl
.
Returns the exact value stored in the table which is observationally
equal to v
but it deals better with dynamic types.
exception Unbound_value of string
exception Incompatible_type of string
val find : t ->
key ->
'a Type.ty -> 'a info
find tbl s ty
returns the binding of
s
in the table
tbl
.
RaisesUnbound_value
if s
is not bound in tbl
.
Incompatible_Type
if ty
was not the type value used to add
the binding of s
in tbl
.