Stdlib320.Env
val empty : 'a env
Empty map
val is_empty : 'a env -> bool
Equivalent to (=) empty
.
val mem : string -> 'a env -> bool
mem s e
is
true
if s
is a key in e
false
otherwiseremove s e
is the same as e
except that s
does not map to anything.
union f e1 e2
is the combination of e1
and e2
, using f
as the combiner. More formally, if mem s e1
and mem s e2
then
find s (union f e1 e2) = x
if f (find s e1) (find s e2) = Some x
not (mem s (union f e1 e2)
otherwisemap f e
is e
with f
applied to each value. More formally, find_opt s (map f e) = Option.map (find s e)
.
filter f e
is e
with the only the mappings (k, v)
such that f k v
holds.
val find : string -> 'a env -> 'a
find s e
is v
if mem s e
and s
maps to v
in e
Raises a Not_found
exception otherwise.
val find_opt : string -> 'a env -> 'a option
Same as the previous function, but is None
in the case of failure.
val to_list : 'a env -> (string * 'a) list
to_list e
is a list of the key-value pairs in e
. More formally, find_opt s e = assoc_opt s (to_list e)
.
val of_list : (string * 'a) list -> 'a env
of_list l
is an map in which each key value pair in l
is added to the empty map, in order from left to right. In particular, if a key is mapped to multiple values in l
, then only the last appears in the of_list l
.