package typerep

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module M.VariantSource

Sourcetype _ tag =
  1. | Tag : ('variant, 'args) Tag.t -> 'variant tag

An existential type used to gather all the tags constituing a variant type. the 'variant parameter is the variant type, it is the same for all the constructors of that variant type. The type of the parameters might be different for each constructor and is thus existential

Sourcetype _ value =
  1. | Value : ('variant, 'args) Tag.t * 'args -> 'variant value

A similar existential constructor to _ tag but this one holds a value whose type is the arguments of the tag constructor. A value of type 'a value is a pair of (1) a value of variant type 'a along with (2) some information about the constructor within the type 'a

Sourcetype 'a t

Witness of a variant type. The parameter is the type of the variant type witnessed.

Sourceval typename_of_t : 'a t -> 'a Typename.t
Sourceval length : 'a t -> int

Returns the number of tags of this variant type definition.

Sourceval tag : 'a t -> int -> 'a tag

Get the nth tag of this variant type, indexed from 0.

Sourceval is_polymorphic : _ t -> bool

Distinguish polymorphic variants and standard variants. Typically, polymorphic variants tags starts with the ` character. Example polymorphic variant: type t = `A | `B standard variant: type t = A | B

Sourceval value : 'a t -> 'a -> 'a value

Pattern matching on a value of this variant type.

Sourceval fold : 'a t -> init:'acc -> f:('acc -> 'a tag -> 'acc) -> 'acc

folding along the tags of the variant type

Sourceval internal_use_only : 'a Variant_internal.t -> 'a t