std/core/types▲toc

Core types.

This module is implicitly imported and all functions and types are always available. These types are required to be defined for the compiler to work correctly (i.e. types like intstd/core/types/int: V or divstd/core/types/div: X).

struct ()std/core/types/(): V

The unit type () is inhabited by just a single value, namely (). See also the voidstd/core/types/void: V type and the boolstd/core/types/bool: V type.

struct (,)std/core/types/(,): (V, V) -> V<a,b>(fst : asnd : b)

A pair of values a and b.

fun fst( ^(a, b) ) : a

Automatically generated. Retrieves the fst constructor field of the (,) type.

fun snd( ^(a, b) ) : b

Automatically generated. Retrieves the snd constructor field of the (,) type.

struct (,,)std/core/types/(,,): (V, V, V) -> V<a,b,c>(fst : asnd : bthd : c)

A triple of values.

fun fst( ^(a, b, c) ) : a

Automatically generated. Retrieves the fst constructor field of the (,,) type.

fun snd( ^(a, b, c) ) : b

Automatically generated. Retrieves the snd constructor field of the (,,) type.

fun thd( ^(a, b, c) ) : c

Automatically generated. Retrieves the thd constructor field of the (,,) type.

struct (,,,)std/core/types/(,,,): (V, V, V, V) -> V<a,b,c,d>(fst : asnd : bthd : cfield4 : d)

A quadruple of values.

fun field4( ^(a, b, c, d) ) : d

Automatically generated. Retrieves the field4 constructor field of the (,,,) type.

fun fst( ^(a, b, c, d) ) : a

Automatically generated. Retrieves the fst constructor field of the (,,,) type.

fun snd( ^(a, b, c, d) ) : b

Automatically generated. Retrieves the snd constructor field of the (,,,) type.

fun thd( ^(a, b, c, d) ) : c

Automatically generated. Retrieves the thd constructor field of the (,,,) type.

struct (,,,,)std/core/types/(,,,,): (V, V, V, V, V) -> V<a,b,c,d,a1>(fst : asnd : bthd : cfield4 : dfield5 : a1)

A quintuple of values.

fun field4( ^(a, b, c, d, a1) ) : d

Automatically generated. Retrieves the field4 constructor field of the (,,,,) type.

fun field5( ^(a, b, c, d, a1) ) : a1

Automatically generated. Retrieves the field5std/core/types/field5: forall<a,b,c,d,a1> ((a, b, c, d, a1)) -> a1 constructor field of the (,,,,) type.

fun fst( ^(a, b, c, d, a1) ) : a

Automatically generated. Retrieves the fst constructor field of the (,,,,) type.

fun snd( ^(a, b, c, d, a1) ) : b

Automatically generated. Retrieves the snd constructor field of the (,,,,) type.

fun thd( ^(a, b, c, d, a1) ) : c

Automatically generated. Retrieves the thd constructor field of the (,,,,) type.

type (<>)std/core/types/(<>): E

The total effect represents the absence of any effect.

type (<|>)std/core/types/(<|>): (X, E) -> E<a,e>

The effect constructor extends an effect with another effect.

effect allocstd/core/types/alloc: H -> X<h>

The alloc effect signifies a function may allocate in a heap h.

type anystd/core/types/any: V

An any type. Used for extern calls.

type boolstd/core/types/bool: V

The type of booleans has two inhabitants: Truestd/core/types/True: bool and Falsestd/core/types/False: bool.

con False
con True

Automatically generated. Tests for the Falsestd/core/types/False: bool constructor of the boolstd/core/types/bool: V type.

Automatically generated. Tests for the Truestd/core/types/True: bool constructor of the boolstd/core/types/bool: V type.

struct boxstd/core/types/box: V -> V<a>(unbox : a)

Explicitly box values using the Boxstd/core/types/Box: forall<a> (unbox : a) -> box<a> constructor.

fun unbox( ^box : boxstd/core/types/box: V -> V<a> ) : a

Automatically generated. Retrieves the unboxstd/core/types/unbox: forall<a> (box : box<a>) -> a constructor field of the boxstd/core/types/box: V -> V type.

type bytestd/core/types/byte: V

A 8-bit unsigned integer. Provides no operations but is used mostly for interaction with external code.

type cfieldstd/core/types/cfield: V -> V<a>

Internal. Internal type for tail recursion module cons (TRMC) optimization. Holds the address to a field of type a in a constructor.

type charstd/core/types/char: V

A unicode character. Characters are unicode codepoints. This is different from a unicode grapheme which represents a single displayed symbol and can consists of multiple codepoints due to combining characters and marks. (see also the std/text/unicode module.).

type ctailstd/core/types/ctail: V -> V<a>

Internal. Internal type for tail recursion module cons (TRMC) optimization.

effect divstd/core/types/div: X

The divergence effect: a divergent function may not terminate.

type doublestd/core/types/double: V

A 64-bit IEEE 754 floating point value. See also std/num/double for more operations on doublestd/core/types/double: Vs.

type edivstd/core/types/ediv: (X, V, E) -> P<a,b,e>

The predicate edivstd/core/types/ediv: (X, V, E) -> P<x,a,e> signifies that if the type a contains a reference to effect constant x then the effect e must contain the divergent effect (divstd/core/types/div: X). This constraint is generated for operations on first-class effects where code can diverge through operations.

type eitherstd/core/types/either: (V, V) -> V<a,b>

The choice type represents one of two possible types a or b.

con Left(left : a)
con Right(right : b)
type float32std/core/types/float32: V

A 32-bit IEEE 754 floating point value. Not supported by the Javascript backend Provides no operations but is used mostly for interaction with external code.

type globalstd/core/types/global: H

The globalstd/core/types/global: H heap is a special heap constant to denote the global shared heap.

effect handledstd/core/types/handled: HX -> X<a>

Handled effects are lifted to an atomic effect using the handledstd/core/types/handled: HX -> X type constructor.

effect handled1std/core/types/handled1: HX1 -> X<a>

Linear effects are lifted to an atomic effect using the handled1std/core/types/handled1: HX1 -> X type constructor.

struct hboxstd/core/types/hbox: V -> V<a>(unhbox : a)

Explicitly heap allocate using the Hbox constructor.

fun unhbox( ^hbox : hboxstd/core/types/hbox: V -> V<a> ) : a

Automatically generated. Retrieves the unhboxstd/core/types/unhbox: forall<a> (hbox : hbox<a>) -> a constructor field of the hboxstd/core/types/hbox: V -> V type.

type hdivstd/core/types/hdiv: (H, V, E) -> P<h,a,e>

The predicate hdivstd/core/types/hdiv: (H, V, E) -> P<h,a,e> signifies that if the type a contains a reference to h, then the effect e must contain the divergent effect (divstd/core/types/div: X). This constraint is generated when reading from the heap (see !) and is necessary to catch cases where code can diverge by storing self referential functions in the heap.

type intstd/core/types/int: V

An arbitrary precision signed integer.

type int32std/core/types/int32: V

A 32-bit signed integer (represented in two's complement). See the std/num/int32 module for operations on 32-bit integers.

needed for markers in std/core/hnd.

type int64std/core/types/int64: V

A 64-bit signed integer (represented in two's complement). See the std/num/int64 module for operations on 64-bit integers.

type intptr_tstd/core/types/intptr_t: V

A signed two's complement integer equal to an intptr_t in C, i.e. it has the same bit-size as a native pointer (void*). Provides no operations but is used mostly for interaction with external code. The Javascript backend uses int64 for this.

effect localstd/core/types/local: H -> X<h>

A local variable var<s,a> points to a value of type a in local scope s.

type local-varstd/core/types/local-var: (H, V) -> V<h,a>

Allocate a fresh local with an initial value.

Assign a new value to a local variable.

type maybestd/core/types/maybe: V -> V<a>

The maybestd/core/types/maybe: V -> V type is used to represent either a value (Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(x)) or Nothingstd/core/types/Nothing: forall<a> maybe<a>. This type is often used to represent values that can be null.

con Just(value : a)
con Nothing
effect ndetstd/core/types/ndet: X

The non-determism effect.

type optionalstd/core/types/optional: V -> V<a>

Optional is used internally by the compiler to pass optional arguments. It is usually displayed as :?a for some type a.

con None

Nonestd/core/types/None: forall<a> ?a is used when an optional argument is not provided.

con Optional(value : a)

The Optionalstd/core/types/Optional: forall<a> (value : a) -> ?a constructor is used when an optional argument is given.

fun is-none( ^optional : ?a ) : boolstd/core/types/bool: V

Automatically generated. Tests for the Nonestd/core/types/None: forall<a> ?a constructor of the optionalstd/core/types/optional: V -> V type.

fun is-optional( ^optional : ?a ) : boolstd/core/types/bool: V

Automatically generated. Tests for the Optionalstd/core/types/Optional: forall<a> (value : a) -> ?a constructor of the optionalstd/core/types/optional: V -> V type.

type orderstd/core/types/order: V

An enumeration to represent order.

con Eq
con Gt
con Lt

Automatically generated. Tests for the Eqstd/core/types/Eq: order constructor of the orderstd/core/types/order: V type.

Automatically generated. Tests for the Gtstd/core/types/Gt: order constructor of the orderstd/core/types/order: V type.

Automatically generated. Tests for the Ltstd/core/types/Lt: order constructor of the orderstd/core/types/order: V type.

effect readstd/core/types/read: H -> X<h>

The read effect: signifies that a function may read from from heap h.

type refstd/core/types/ref: (H, V) -> V<h,a>

A reference refstd/core/types/ref: (H, V) -> V<h,a> points to a value of type a in heap h.

Read the value of a reference.

Modify the value of a reference. This is especially useful when the reference contains a vector, because getting the vector into a local variable and then setting it back into the reference later would mean that we hold on to a copy (and we can't update the vector in place then!). In contrast, this function will pass its ownership to the given function.

Allocate a fresh reference with an initial value.

fun set( ^ref : refstd/core/types/ref: (H, V) -> V<h,a>, assigned : a ) : (writestd/core/types/write: H -> X<h>) types/()

Assign a new value to a reference.

type reusestd/core/types/reuse: V

Internal type used for in-place update of unique pattern matches.

type ssize_tstd/core/types/ssize_t: V

A signed two's complement integer equal to a signed size_t in C, i.e. it can hold the byte size of any object, in particular the maximum possible byte size of a vector or string. Provides no operations but is used mostly for interaction with external code. The Javascript backend uses int32 for this.

alias ststd/core/types/st: H -> E<h> = <readstd/core/types/read: H -> X<h>,writestd/core/types/write: H -> X<h>,allocstd/core/types/alloc: H -> X<h>>

Stateful funs can manipulate heap h using allocations, reads and writes.

type stringstd/core/types/string: V

A string is a sequence of unicode character points (char). The encoding of a string is internal and there is no constant-time indexing of characters in a string. Use the sslice type for efficient matching and retrieving sub-strings from string.
See also the std/text/string module.

type vectorstd/core/types/vector: V -> V<a>

The type of immutable arrays is called vectorstd/core/types/vector: V -> V.

type voidstd/core/types/void: V

The voidstd/core/types/void: V type is empty and has no constructors. See also the () unit type and the boolstd/core/types/bool: V type.

effect writestd/core/types/write: H -> X<h>

The write effect: signifies that a function may write to heap h.

fun byref( loc : a ) : a
fun id( x : a ) : a
fun keep( x : a ) : a
fun local-scope( action : forall<h> () -> <localstd/core/types/local: H -> X<h>|e> a ) : e a

If local mutation is unobservable, the localstd/core/types/local: H -> X effect can be erased by using the local-scopestd/core/types/local-scope: forall<a,e> (action : forall<h> () -> <local<h>|e> a) -> e a function. See also: State in Haskell, by Simon Peyton Jones and John Launchbury.

fun run( action : forall<h> () -> <allocstd/core/types/alloc: H -> X<h>,readstd/core/types/read: H -> X<h>,writestd/core/types/write: H -> X<h>|e> a ) : e a

If a heap effect is unobservable, the heap effect can be erased by using the runstd/core/types/run: forall<e,a> (action : forall<h> () -> <alloc<h>,read<h>,write<h>|e> a) -> e a fun. See also: State in Haskell, by Simon Peyton Jones and John Launchbury.

fun unsafe-decreasing( x : a ) : a

Unsafe. Mark a function parameter as decreasing to suppress the non-termination effect (divstd/core/types/div: X).

fun unsafe-no-div( action : () -> <divstd/core/types/div: X|e> a ) : e a

Unsafe. This function pretends the give action is terminating.

fun unsafe-no-ndet( action : () -> <ndetstd/core/types/ndet: X|e> a ) : e a

Unsafe. This function pretends the give action was deterministic.

fun unsafe-total( action : () -> e a ) : a

Unsafe. This function calls a function and pretends it did not have any effect at all.