Spec-Zone.ru › OCaml
☰The OCaml language
  • The OCaml language
  • Language extensions

Chapter 12 Language extensions

10 Generalized algebraic datatypes

Generalized algebraic datatypes, or GADTs, extend usual sum types in two ways: constraints on type parameters may change depending on the value constructor, and some type variables may be existentially quantified. They are described in chapter 7.

(Introduced in OCaml 4.00)

constr-decl ::= ...
∣ constr-name : [ constr-args -> ] typexpr
type-param ::= ...
∣ [variance] _

Refutation cases. (Introduced in OCaml 4.03)

matching-case ::= pattern [when expr] -> expr
∣ pattern -> .

Explicit naming of existentials. (Introduced in OCaml 4.13.0)

pattern ::= ...
∣ constr ( type { typeconstr-name }+ ) ( pattern )
« Overriding in open statementsSyntax for Bigarray access »
Copyright © 2026 Institut National de Recherche en Informatique et en Automatique

© 1995-2026 INRIA.
https://ocaml.org/manual/5.5/gadts.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API