Title: Theory / Unimportant / CS / Programming / oCaml / Manual{ / 04 variants;
Tags: hasNotNewEffectReturnsMeaning type FromInstruction computer_to_instruction fromMath some_instruction

Smaller0: apart from the optional argument, every parameters are given
Greater0: an optional argument's default value is taken
Chapter: 4
Section: 1
Hide middle: yes
Smaller1: an unlabelled value given after this optional argument has been set
Connect Smaller0: or

Typ: [>foo_1| ... |foo_n]
Meaning: The type of variants containing at least the foo_i
Language: ocaml
Chapter: 4
Section: 2
Context: Variant declaration

Typ: [<foo_1| ... |foo_n]
Meaning: The type of variants containing at least the foo_i
Language: ocaml
Chapter: 4
Section: 2
Context: Variant declaration

Typ: [ foo_1| ... |foo_n]
Meaning: The type of variants containing exactly the foo_i
Language: ocaml
Chapter: 4
Section: 2
Context: Variant declaration

Typ: type_1 & type_2
Meaning: The intersection of type_1 and of type_2
Language: ocaml
Chapter: 4
Section: 2

Typ: type_1 :> type_2
Meaning: An element of type_1 considered as an element of type_2
Language: oCaml
Chapter: 4
Section: 2
Assuming: type_1 is a subset of type_2

Instruction: #myvariant ->
Effect: match against all variants of myvariant
Language: ocaml
Chapter: 4
Section: 2
Variables: myvariant: a type of polymorphic variant
Where to use it: pattern matching

Instruction: `Constructor ( expr)
Effect: Evaluates expr, assigns it to a label `Constructor
Language: ocaml
Chapter: 4
Section: 2

Typ: ...| `foo |...
Meaning: one of the variant of the type declared is `foo
Page: https://caml.inria.fr/pub/docs/manual-ocaml/lablexamples.html#sec46
Language: ocaml
Context: Variant type declaration

Typ: ...| `foo of (bar_1, ..., bar_n)|...
Meaning: one of the variant of the type declared is `foo, with n parameters of type bar_i
Page: https://caml.inria.fr/pub/docs/manual-ocaml/lablexamples.html#sec46
Language: ocaml
Context: Variant type declaration

Typ: ...| typ|...
Meaning: The element of the variant contains the type of typ
Page: https://caml.inria.fr/pub/docs/manual-ocaml/lablexamples.html#sec46
Language: Ocaml
Context: Variant type declaration
Variables: typ a variant type