Comparison of programming languages (algebraic data type)

This article compares the syntax for defining and instantiating an algebraic data type (ADT), sometimes also referred to as a tagged union, in various programming languages.

Ceylon
In Ceylon, an ADT may be defined with:

And instantiated as:

Clean
In Clean, an ADT may be defined with:

And instantiated as:

Coq
In Coq, an ADT may be defined with:

And instantiated as:

C++
In C++, an ADT may be defined with:

And instantiated as:

Dart
In Dart, an ADT may be defined with:

And instantiated as:

Elm
In Elm, an ADT may be defined with:

And instantiated as:

F#
In F#, an ADT may be defined with:

And instantiated as:

F*
In F*, an ADT may be defined with:

And instantiated as:

Free Pascal
In Free Pascal (in standard ISO Pascal mode ), an ADT may be defined with variant records:

And instantiated as:

Haskell
In Haskell, an ADT may be defined with:

And instantiated as:

Haxe
In Haxe, an ADT may be defined with:

And instantiated as:

Hope
In Hope, an ADT may be defined with:

And instantiated as:

Idris
In Idris, an ADT may be defined with:

And instantiated as:

Java
In Java, an ADT may be defined with:

And instantiated as:

Julia
In Julia, an ADT may be defined with:

And instantiated as:

Kotlin
In Kotlin, an ADT may be defined with:

And instantiated as:

Limbo
In Limbo, an ADT may be defined with:

And instantiated as:

Mercury
In Mercury, an ADT may be defined with:

And instantiated as:

Miranda
In Miranda, an ADT may be defined with:

And instantiated as:

Nemerle
In Nemerle, an ADT may be defined with:

And instantiated as:

Nim
In Nim, an ADT may be defined with:

And instantiated as:

OCaml
In OCaml, an ADT may be defined with:

And instantiated as:

Opa
In Opa, an ADT may be defined with:

And instantiated as:

OpenCog
In OpenCog, an ADT may be defined with:

PureScript
In PureScript, an ADT may be defined with:

And instantiated as:

Python
In Python, an ADT may be defined with:

And instantiated as:

Racket
In Typed Racket, an ADT may be defined with:

And instantiated as:

Reason
In Reason, an ADT may be defined with:

And instantiated as:

ReScript
In ReScript, an ADT may be defined with:

And instantiated as:

Rust
In Rust, an ADT may be defined with:

And instantiated as:

Scala 2
In Scala 2, an ADT may be defined with:

And instantiated as:

Scala 3
In Scala 3, an ADT may be defined with:

And instantiated as:

Standard ML
In Standard ML, an ADT may be defined with:

And instantiated as:

Swift
In Swift, an ADT may be defined with:

And instantiated as:

TypeScript
In TypeScript, an ADT may be defined with:

And instantiated as:

Visual Prolog
In Visual Prolog, an ADT may be defined with:

And instantiated as: