std/core/types▲toc

Primitive types and functions.

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)

The kinds of types are all builtin:

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 external 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

Logical conjunction. This is compiled specially avoid evaluating the second argument if x==Falsestd/core/types/False: bool.

Logical disjunction. This is compiled specially avoid evaluating the second argument if x==Truestd/core/types/True: bool.

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.

Logical negation.

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.

Automatically generated. Retrieves the unbox constructor field of the boxstd/core/types/box: V -> V type.

type cctxstd/core/types/cctx: (V, V) -> V<a,b>

First-class constructor context (for tail recursion modulo cons (TRMC) optimization). See also samples/learn/contexts for further examples.

fun cctx/(++.)( c : cctxstd/core/types/cctx: (V, V) -> V<a,b>, x : b ) : a

Apply a constructor context to its final value (of type b), which is put into the hole of the context, and returns the root of the resulting structure a. This is a constant time operation for unique contexts.

(ctx Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(1,_)) ++ (ctx Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,Nilstd/core/types/Nil: forall<a> list<a>)) ++. 3 == [1,3].

Create an empty context. Usually written directly as an empty context ctx _.

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 std/core/charstd/core/char and the std/text/unicodestd/text/unicode module).

alias ctxstd/core/types/ctx: V -> V<a> = cctxstd/core/types/cctx: (V, V) -> V<a,a>

A first-class constructor context where the hole is of the same type as the root of the structure.

effect divstd/core/types/div: X

The divergence effect: a divergent function may not terminate.

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 effect-extendstd/core/types/effect-extend: (X, E) -> E<a,e>

The effect constructor extends an effect row with another effect. Usually written as <_|_>.

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

The choice type represents one of two possible types a or b. See also std/core/eitherstd/core/either.

con Left(left : a)

Left result, usually used for errors.

con Right(right : b)

Right result, usually used for success.

type float32std/core/types/float32: V

A 32-bit IEEE 754 single precision floating point value. Provides currently no operations and currently only used for storage and for interaction with external code.

type float64std/core/types/float64: V

A 64-bit IEEE 754 double precision floating point value. See std/num/float64std/num/float64 for operations on float64std/core/types/float64: Vs.

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: ((E, V) -> V) -> X<a>

Handled effects are lifted to an atomic effect using the handledstd/core/types/handled: ((E, V) -> V) -> X type constructor All user defined effects are handledstd/core/types/handled: ((E, V) -> V) -> X since they require a handler to be dismissed. In contrast, some built-in effects, like divstd/core/types/div: X or ststd/core/types/st: H -> E do not require a handler as these are handled by the system. In particular, the runtime evidence vector only contains handledstd/core/types/handled: ((E, V) -> V) -> X (and handled1std/core/types/handled1: ((E, V) -> V) -> X) effects.

effect handled1std/core/types/handled1: ((E, V) -> V) -> X<a>

Linear effects are lifted to an atomic effect using the handled1std/core/types/handled1: ((E, V) -> V) -> X type constructor.

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. See std/core/intstd/core/int for integer operations.

type int16std/core/types/int16: V

A 16-bit signed integer (represented in two's complement). Provides no operations and used only for storage and interaction with external code.

type int32std/core/types/int32: V

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

type int64std/core/types/int64: V

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

type int8std/core/types/int8: V

A 8-bit signed integer (represented in two's complement). Provides no operations and used only for storage and interaction with external code.

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.

type liststd/core/types/list: V -> V<a>

The type of lists, which can be either empty (Nilstd/core/types/Nil: forall<a> list<a>) or an element followed by a list (Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>). See std/core/liststd/core/list for operations on lists.

con Cons(head : atail : liststd/core/types/list: V -> V<a>)

A head element followed by the tail of the list.

con Nil

The empty list.

Automatically generated. Tests for the Nilstd/core/types/Nil: forall<a> list<a> constructor of the liststd/core/types/list: V -> V type.

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

A local heap effect.

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

A local variable local-varstd/core/types/local-var: (H, V) -> V<s,a> points to a value of type a in local scope s.

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. See also std/core/maybestd/core/maybe.

con Just(value : a)

A single result.

con Nothing

No result.

effect ndetstd/core/types/ndet: X

The non-determinism effect.

effect nhandledstd/core/types/nhandled: ((E, V) -> V) -> X<a>

Named effects are lifted to an atomic effect with the nhandledstd/core/types/nhandled: ((E, V) -> V) -> X type constructor. In contrast to handledstd/core/types/handled: ((E, V) -> V) -> X effects, these effects are not passed in the evidence vector.

effect nhandled1std/core/types/nhandled1: ((E, V) -> V) -> X<a>

Linear named effects are lifted to an atomic effect using the nhandled1std/core/types/nhandled1: ((E, V) -> V) -> X type constructor.

type orderstd/core/types/order: V

An enumeration to represent order: Ltstd/core/types/Lt: order, Eqstd/core/types/Eq: order, or Gtstd/core/types/Gt: order. See also std/core/orderstd/core/order.

con Eq

Equal.

con Gt

Greater-than.

con Lt

Lower-than.

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.

type order2std/core/types/order2: V -> V<a>

Represent two elements in ascending order. This is used to allow comparison on elements to be used linearly for fip functions. See also std/core/orderstd/core/order.

con Eq2(eq : a)

The elements compared equal (with value eq).

con Gt2(lt : agt : a)

The elements compared greater-than, with lt < gt.

con Lt2(lt : agt : a)

The elements compared lower-than, with lt < gt.

struct padstd/core/types/pad: V

A padding type pad. This is sometimes used for fbip programming to match up the size of constructors for reuse.

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 passes the 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>) ()

Assign a new value to a reference.

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 functions 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 std/core/stringstd/core/string and std/core/sslicestd/core/sslice for string operations.

type totalstd/core/types/total: E

The total effect represents the absence of any effect. Usually written as <>.

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

A pair of values a and b. Usually written as (x,y) (for types and terms).

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

Automatically generated. Retrieves the fst constructor field of the tuple2std/core/types/tuple2: (V, V) -> V type.

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

Automatically generated. Retrieves the snd constructor field of the tuple2std/core/types/tuple2: (V, V) -> V type.

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

A triple of values. Usually written as (x,y,z) (for types and terms).

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

Automatically generated. Retrieves the fst constructor field of the tuple3std/core/types/tuple3: (V, V, V) -> V type.

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

Automatically generated. Retrieves the snd constructor field of the tuple3std/core/types/tuple3: (V, V, V) -> V type.

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

Automatically generated. Retrieves the thd constructor field of the tuple3std/core/types/tuple3: (V, V, V) -> V type.

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

A quadruple of values. Usually written as (a,b,c,d) (for types and terms).

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

Automatically generated. Retrieves the field4 constructor field of the tuple4std/core/types/tuple4: (V, V, V, V) -> V type.

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

Automatically generated. Retrieves the fst constructor field of the tuple4std/core/types/tuple4: (V, V, V, V) -> V type.

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

Automatically generated. Retrieves the snd constructor field of the tuple4std/core/types/tuple4: (V, V, V, V) -> V type.

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

Automatically generated. Retrieves the thd constructor field of the tuple4std/core/types/tuple4: (V, V, V, V) -> V type.

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

A quintuple of values. Usually written as (a,b,c,d,e) (for types and terms).

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

Automatically generated. Retrieves the field4 constructor field of the tuple5std/core/types/tuple5: (V, V, V, V, V) -> V type.

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

Automatically generated. Retrieves the field5 constructor field of the tuple5std/core/types/tuple5: (V, V, V, V, V) -> V type.

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

Automatically generated. Retrieves the fst constructor field of the tuple5std/core/types/tuple5: (V, V, V, V, V) -> V type.

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

Automatically generated. Retrieves the snd constructor field of the tuple5std/core/types/tuple5: (V, V, V, V, V) -> V type.

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

Automatically generated. Retrieves the thd constructor field of the tuple5std/core/types/tuple5: (V, V, V, V, V) -> V type.

struct unitstd/core/types/unit: V

The unit type unitstd/core/types/unit: V is inhabited by just a single value, namely Unitstd/core/types/Unit: (). Usually the type and constructor are written as (). See also the voidstd/core/types/void: V type and the boolstd/core/types/bool: V type.

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

The type of immutable polymorphic arrays is called vectorstd/core/types/vector: V -> V. See std/core/vectorstd/core/vector for vector operations.

type voidstd/core/types/void: V

The voidstd/core/types/void: V type is empty and has no constructors. See also the unitstd/core/types/unit: V 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 id( x : a ) : a

The identity function returns its argument unchanged.

fun keep( x : a ) : a

Prevent inlining an expression by passing it to keepstd/core/types/keep: forall<a> (x : a) -> a (which is a non-inlineable identity function).

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

Internal: 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 mask-st( () -> e a ) : (() -> <ststd/core/types/st: H -> E<h>|e> a)

Mask the state effect. This is more convenient than masking each readstd/core/types/read: H -> X, writestd/core/types/write: H -> X, and allocstd/core/types/alloc: H -> X effect separately.

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.