Skip to main content
Version: Next

Native Types

This page describes the built-in data shapes that are part of the language itself rather than stdlib modules.

Tasks​

Type form: 'a task

FormSignatureDescription
Task.spawn (fun () -> expr)(unit -> 'a) -> 'a taskStarts concurrent work and returns a task handle.
Task.await taskValue'a task -> 'aWaits for completion and returns the task result.
let pending = Task.spawn (fun () -> 40 + 2)
let answer = Task.await pending

Tasks are opaque values. They do not expose indexers or fields. The 'a task type is native to the language, while Task.spawn and Task.await come from the default runtime extern registry and may be omitted by an embedding host.

Lists​

Type form: 'a list

FormSignatureDescription
[]'a listEmpty list literal.
head :: tail'a -> 'a list -> 'a listPrepends one item to a list.
left @ right'a list -> 'a list -> 'a listConcatenates two lists.
values[index]'a list -> int -> 'a optionZero-based optional indexer. Negative or out-of-range indices return None.
let xs = [10; 20; 30]
let maybeSecond = xs[1]

Maps​

Type forms: 'v map for string keys, or 'v map['key] for explicit key types.

Map keys may be string, int, bool, or a union whose cases all have no payload. Use value map[key] for explicit key annotations; value map remains the string-keyed shorthand.

FormSignatureDescription
{}'v map['key]Empty map literal.
{ [key] = value }'key -> 'v -> 'v map['key]Map literal entry syntax.
values[key]'v map['key] -> 'key -> 'v optionOptional key lookup. Missing keys return None.
{ ..tail }'v map['key] -> 'v map['key]Spread syntax used when building or updating a map.
let scores = { ["math"] = 18; ["english"] = 16 }
let maybeMath = scores["math"]

Options​

Type form: 'a option

FormSignatureDescription
Some value'a -> 'a optionWraps a present value.
None'a optionRepresents the absence of a value.

Use pattern matching or Option.* helpers to consume options.

Tuples​

Type form: (t1 * t2 * ...)

FormSignatureDescription
(a, b)'a * 'bTuple literal.
let (a, b) = value('a * 'b) -> unitTuple destructuring in bindings.
tuple pattern matching('a * 'b) -> 'rUse match value with (a, b) -> ... to decompose tuples.

Tuples do not have a native indexer. Destructure them instead.

Records​

Type form: { Field: t; ... }

FormSignatureDescription
{ Name = value }field-set dependentRecord literal.
record.Field{ Field: 'a; ... } -> 'aField access by name.
{ record with Field = value }same record type -> same record typeRecord update syntax.

Unions​

Type form: type Shape = | Point | Circle of int

FormSignatureDescription
Casecase dependentUnion constructor without payload.
Case valuepayload type -> union typeUnion constructor with payload.
union pattern matchingunion type -> 'rUse match value with Case x -> ... to branch on union cases.

Scalars​

Primitive built-in types:

  • int
  • float
  • bool
  • string
  • unit

These do not use indexers. For parsing and formatting helpers, see Int, Float, Bool Modules and String Module.

Numeric meta-type​

numeric constrains inference to int or float. It is available in function annotations and inferred editor signatures, with no additional runtime value shape.

OperationOperand typesResult
+, -, *, /Two int values or two float valuesSame concrete type as the operands
<, >, <=, >=Two int values or two float valuesbool
%Two int valuesint

Mixed numeric types and nonnumeric operands are rejected. + does not concatenate strings, lists, or maps. Use String.concat for strings and @ for lists.

See Type System for the type hierarchy and specialization examples.