Module Gist.Variant

Variants for gist processors.

Variant cases

module Case : sig ... end

Variant cases.

Variants

type 'v t

The type for representing variant types of type 'v.

val make : 'v Case.t list -> case_index:('v -> int) -> 'v t

make cases ~case_index is a variant type with cases described by cases and whose values are attributed a case in the cases list with the zero-based case_index function.

val cases : 'v t -> 'v Case.t iarray

cases vt are the cases of vt.

val case_index : 'v t -> 'v -> int

case_index vt is the function that given a value of the variant type attributes it a case in the array cases vt.

val case : 'v t -> 'v -> 'v Case.t

case vt v is Iarray.get (cases vt) (case_index vt).

val is_polymorphic_variant : 'v t -> bool

is_polymorphic_variant vt is true if and only if vt is a polymorphic variant (checked by determining if the first case's Case.name starts with a backtick).