Module Tuple_type_intf

module Tuple_type_intf: sig .. end
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.


module type Slots = sig .. end
module type Slot = sig .. end

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.

A Slot.t represents a slot in a tuple type.