Slots
has types t1
, ..., t12
of arities 1 to 12 that are isomorphic to tuple
types of the corresponding arities. Type ('a0, ..., 'a<N-1>) t<N>
corresponds to
'a0 * ... * 'a<N-1>
.
Each type ti
is an instance of type ('tuple, 'variant) t
, in which 'tuple
is
the tuple type 'a0 * ... * 'a<N-1>
and 'variant
is an encoding of the tuple type
in the form: [ `S0 of `a0 | `S1 of `a1 | ... | `S<N-1> of `a<N-1> ]
.
The encoding of the slots using a polymorphic variant allows one to write functions that are polymorphic in the tuple type, and require that a tuple have a certain slot, but allow more slots.
We make t
itself a polymorphic variant type so that one can easily encode cyclic
types, e.g. lists, like:
type 'a slots = ('a, 'a slots Pointer.t) Slots.t2
Observe that slots
in the above is cyclic, but that OCaml allows it because the
definition expands to:
type 'a slots = [ `Slots of ('a * 'a slots Pointer.t,
[ `S0 of 'a
| `S1 of 'a slots Pointer.t
]
) u
]
Ultimately, a Slots.t
is used as a phantom type that ensures consistent usage of
the tuples in the data structure containing them.
include sig ... end
val sexp_of_t : ('tuple ‑> Base.Sexp.t) ‑> ('variant ‑> Base.Sexp.t) ‑> ('tuple, 'variant) t ‑> Base.Sexp.t
val slots_per_tuple : (_, _) t ‑> Core_kernel__.Import.int
include sig ... end
val sexp_of_t1 : ('a0 ‑> Base.Sexp.t) ‑> 'a0 t1 ‑> Base.Sexp.t
include sig ... end
val sexp_of_t2 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a0, 'a1) t2 ‑> Base.Sexp.t
include sig ... end
val sexp_of_t3 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2) t3 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3) t4
= ('a0 * 'a1 * 'a2 * 'a3, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 ]) t
include sig ... end
val sexp_of_t4 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3) t4 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4) t5
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 ]) t
include sig ... end
val sexp_of_t5 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4) t5 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5) t6
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 ]) t
include sig ... end
val sexp_of_t6 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5) t6 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6) t7
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 | `S6 of 'a6 ]) t
include sig ... end
val sexp_of_t7 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a6 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6) t7 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7) t8
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 | `S6 of 'a6 | `S7 of 'a7 ]) t
include sig ... end
val sexp_of_t8 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a6 ‑> Base.Sexp.t) ‑> ('a7 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7) t8 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8) t9
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 | `S6 of 'a6 | `S7 of 'a7 | `S8 of 'a8 ]) t
include sig ... end
val sexp_of_t9 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a6 ‑> Base.Sexp.t) ‑> ('a7 ‑> Base.Sexp.t) ‑> ('a8 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8) t9 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9) t10
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 | `S6 of 'a6 | `S7 of 'a7 | `S8 of 'a8 | `S9 of 'a9 ]) t
include sig ... end
val sexp_of_t10 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a6 ‑> Base.Sexp.t) ‑> ('a7 ‑> Base.Sexp.t) ‑> ('a8 ‑> Base.Sexp.t) ‑> ('a9 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9) t10 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10) t11
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9 * 'a10, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 | `S6 of 'a6 | `S7 of 'a7 | `S8 of 'a8 | `S9 of 'a9 | `S10 of 'a10 ]) t
include sig ... end
val sexp_of_t11 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a6 ‑> Base.Sexp.t) ‑> ('a7 ‑> Base.Sexp.t) ‑> ('a8 ‑> Base.Sexp.t) ‑> ('a9 ‑> Base.Sexp.t) ‑> ('a10 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10) t11 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11) t12
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9 * 'a10 * 'a11, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 | `S6 of 'a6 | `S7 of 'a7 | `S8 of 'a8 | `S9 of 'a9 | `S10 of 'a10 | `S11 of 'a11 ]) t
include sig ... end
val sexp_of_t12 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a6 ‑> Base.Sexp.t) ‑> ('a7 ‑> Base.Sexp.t) ‑> ('a8 ‑> Base.Sexp.t) ‑> ('a9 ‑> Base.Sexp.t) ‑> ('a10 ‑> Base.Sexp.t) ‑> ('a11 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11) t12 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11, 'a12) t13
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9 * 'a10 * 'a11 * 'a12, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 | `S6 of 'a6 | `S7 of 'a7 | `S8 of 'a8 | `S9 of 'a9 | `S10 of 'a10 | `S11 of 'a11 | `S12 of 'a12 ]) t
include sig ... end
val sexp_of_t13 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a6 ‑> Base.Sexp.t) ‑> ('a7 ‑> Base.Sexp.t) ‑> ('a8 ‑> Base.Sexp.t) ‑> ('a9 ‑> Base.Sexp.t) ‑> ('a10 ‑> Base.Sexp.t) ‑> ('a11 ‑> Base.Sexp.t) ‑> ('a12 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11, 'a12) t13 ‑> Base.Sexp.t
type ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11, 'a12, 'a13) t14
= ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9 * 'a10 * 'a11 * 'a12 * 'a13, [ `S0 of 'a0 | `S1 of 'a1 | `S2 of 'a2 | `S3 of 'a3 | `S4 of 'a4 | `S5 of 'a5 | `S6 of 'a6 | `S7 of 'a7 | `S8 of 'a8 | `S9 of 'a9 | `S10 of 'a10 | `S11 of 'a11 | `S12 of 'a12 | `S13 of 'a13 ]) t
include sig ... end
val sexp_of_t14 : ('a0 ‑> Base.Sexp.t) ‑> ('a1 ‑> Base.Sexp.t) ‑> ('a2 ‑> Base.Sexp.t) ‑> ('a3 ‑> Base.Sexp.t) ‑> ('a4 ‑> Base.Sexp.t) ‑> ('a5 ‑> Base.Sexp.t) ‑> ('a6 ‑> Base.Sexp.t) ‑> ('a7 ‑> Base.Sexp.t) ‑> ('a8 ‑> Base.Sexp.t) ‑> ('a9 ‑> Base.Sexp.t) ‑> ('a10 ‑> Base.Sexp.t) ‑> ('a11 ‑> Base.Sexp.t) ‑> ('a12 ‑> Base.Sexp.t) ‑> ('a13 ‑> Base.Sexp.t) ‑> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11, 'a12, 'a13) t14 ‑> Base.Sexp.t
val t1 : _ t1
val t2 : (_, _) t2
val t3 : (_, _, _) t3
val t4 : (_, _, _, _) t4
val t5 : (_, _, _, _, _) t5
val t6 : (_, _, _, _, _, _) t6
val t7 : (_, _, _, _, _, _, _) t7
val t8 : (_, _, _, _, _, _, _, _) t8
val t9 : (_, _, _, _, _, _, _, _, _) t9
val t10 : (_, _, _, _, _, _, _, _, _, _) t10
val t11 : (_, _, _, _, _, _, _, _, _, _, _) t11
val t12 : (_, _, _, _, _, _, _, _, _, _, _, _) t12
val t13 : (_, _, _, _, _, _, _, _, _, _, _, _, _) t13
val t14 : (_, _, _, _, _, _, _, _, _, _, _, _, _, _) t14