summaryrefslogtreecommitdiff
path: root/lib/value/property.mli
blob: af83dc0285383f361fad8eb03eafdcb78f59425d (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
(** A property of a value: a field name tied to its type.

    A property is the typed handle used to read a field of a value with
    {!Value.get}: the {!Model.Types.t} of the field together with its
    {!Model.Identifier.t} name. *)

type 'typ t = {
  name : Model.Identifier.t;  (** The internal name of the field *)
  typ : 'typ;  (** The type of the field, e.g. a ['target multireference] *)
}
(** A {!Model.Types.t} together with the field's name *)

val named : name:Model.Identifier.t -> typ:'typ -> 'typ t
(** Build a property from a name and a type — no uniqueness involved, so values
    built on the fly denote the same field *)

val name : 'typ t -> Model.Identifier.t
(** The name of the field *)

val typ : 'typ t -> 'typ
(** The type of the field *)

val provably_equal :
  ('a, 'x, 'c) Model.Types.t t ->
  ('b, 'y, 'c) Model.Types.t t ->
  ('x, 'y) Type.eq option
(** [provably_equal p1 p2] is [Some Equal] iff [p1] and [p2] denote the same
    field — same name — and their types match, which also proves that their
    ['ocaml] representations are equal *)

val same : ('a, 'x, 'c) Model.Types.t t -> ('b, 'y, 'c) Model.Types.t t -> bool
(** [same p1 p2] is [true] iff [p1] and [p2] denote the same field with matching
    types *)