Prelude
Types
maybe

The maybe type encapsulates an optional value. A value of type maybe<a> either contains a value of type a (represented as just<a>), or it is empty (represented as nothing<a>).

maybe<a>
Constructors
Functions
just
Type Signature
(a) -> maybe<a>
nothing
Type Signature
() -> maybe<a>
Types
either

The either type represents values with two possibilities. A value of type A value of type either<a,b> is either left a or right b.

either<a,b>
Constructors
Functions
left
Type Signature
(a) -> either<a,b>
right
Type Signature
(b) -> either<a, b>
Types
alias list

The list record type represents an ordered series of elements of a given length.

alias list<a, n : int> = { data : a[n], length : uint32 }
Members
data : a[n]

The internal array used to store the elements.

length : uint32

The length of the list

alias charlist

The charlist alias represents a list of extended ASCII characters at most length n (this does not include the final null byte). To get the length of the string not including the null byte, use CharList:length.

alias charlist<n : int> = list<uint8, n+1>
Members

data : uint8[n+1] length : uint32

sig

The signal type encapsulates the concept of a signal. At any point in time, a signal may having nothing travelling through it, or something travelling through it.

sig<a>
Constructors
Functions
signal
Type Signature
(maybe<a>) -> sig<a>
extractptr

Extracts the contained ptr from a rcptr (reference counted pointer).

Type Signature
(rcptr) -> ptr
Parameters
p : rcptr

The pointer to extract the rawpointer from

Returns

The extracted rawpointer

makerc

Creates a reference counting cell to attach to a pointer. When the reference count reaches 0, the finalizer will be called with the underlying ptr as a parameter. The finalizer must have an empty closure.

Type Signature
(ptr, (||)(ptr) -> unit) -> rcptr
Parameters

p : The pointer that will be garbage collected once the counter reaches 0.  finalizer : (||)(ptr) -> unit the destructor that will be called once there

Returns

A new reference counted pointer.

compose

Composes two functions together.

Type Signature
((b) -> c, (a) -> b) -> ((a) -> c)
Parameters
f : (b) -> c

The second function to compose

g : (a) -> b

The first function to compose

Returns

A composed function equivalent to f(g(x))

id

The identity function.

Type Signature
(a) -> a
Parameters
x : a

The value to return

Returns

The input value

curry

Curries a function with an argument arity of 2.

Type Signature
((a, b) -> c) -> ((a) -> (b) -> c)
Parameters
f : (a, b) -> c

The function to curry.

Returns

A curried function

uncurrcy

Uncurries a function with an argument arity of 2.

Type Signature
((a) -> (b) -> c) -> ((a, b) -> c)
Parameters
f : (a) -> (b) -> c

The function to uncurry.

Returns

A uncurried function

curry3

Curries a function with an argument arity of 3.

Type Signature
((a, b, c) -> d) -> ((a) -> (b) -> (c) -> d)
Parameters
f : (a, b, c) -> d

The function to curry.

Returns

A curried function

uncurry3

Uncurries a function with an argument arity of 3.

Type Signature
((a) -> (b) -> (c) -> d) -> ((a, b, c) -> d)
Parameters
f : (a) -> (b) -> (c) -> d

The function to uncurry

Returns

An uncurried function

eq

A function representation of the equality operator

Type Signature
(a, a) -> bool
Parameters
x : a

The first value to compare

y : a

The second value to compare

Returns

True if the values are equivalent, false otherwise.

neq

A function representation of the inequality operator

Type Signature
(a, a) -> bool
Parameters
x : a

The first value to compare

y : a

The second value to compare

Returns

False if the values are equivalent, true otherwise.

gt

A function representation of the greater than operator

Type Signature
(a, b) -> bool where a : num, b : num
Parameters
x : a

The first value to compare

y : b

The second value to compare

Returns

True if x > y, false otherwise.

geq

A function representation of the greater than or equal operator

Type Signature
(a, b) -> bool where a : num, b : num
Parameters
x : a

The first value to compare

y : b

The second value to compare

Returns

True if x >= y, false otherwise.

lt

A function representation of the less than operator

Type Signature
(a, b) -> bool where a : num, b : num
Parameters
x : a

The first value to compare

y : b

The second value to compare

Returns

True if x < y, false otherwise.

leq

A function representation of the less than or equal operator

Type Signature
(a, b) -> bool where a : num, b : num
Parameters
x : a

The first value to compare

y : b

The second value to compare

Returns

True if x <= y, false otherwise.

notf

A function representation of the not operator

Type Signature
(bool) -> bool
Parameters
x : bool

The value to take the logical inverse of

Returns

The logical inverse of x

andf

A function representation of the && operator

Type Signature
(bool, bool) -> bool
Parameters
x : bool

The first boolean value

y : bool

The second boolean value

Returns

x && y

orf

A function representation of the or operator

Type Signature
(bool, bool) -> bool
Parameters
x : bool

The first boolean value

y : bool

The second boolean value

Returns

x or y

apply2

Applies a tuple of values to the given function

Type Signature
((a,b) -> c, (a,b)) -> c
Parameters
f : (a,b) -> c

The function to apply

tup : (a,b)

The values to pass to the function

Returns

The result of the values held in the tuple applied to f

apply3

Applies a tuple of values to the given function

Type Signature
((a,b,c) -> d, (a,b,c)) -> d
Parameters
f : (a,b,c) -> d

The function to apply

tup : (a,b,c)

The values to pass to the function

Returns

The result of the values held in the tuple applied to f

apply4

Applies a tuple of values to the given function

Type Signature
((a,b,c,d) -> e, (a,b,c,d)) -> e
Parameters
f : (a,b,c,d) -> e

The function to apply

tup : (a,b,c,d)

The values to pass to the function

Returns

The result of the values held in the tuple applied to f

fst

Gives the first element of a two element tuple.

Type Signature
((a, b)) -> a
Parameters
tup : (a, b)

The tuple to extract the first element from

Returns

The first element of the two element tuple.

snd

Gives the second element of a two element tuple.

Type Signature
((a, b)) -> b
Parameters
tup : (a, b)

The tuple to extract the second element from

Returns

The second element of the two element tuple.

add

Adds the two arguments together.

Type Signature
(a, a) -> a where a : num
Parameters
numA : a

The first number

numB : a

The second number

Returns

The sum of the two numbers

sub

Subtracts the two arguments

Type Signature
(a, a) -> a where a : num
Parameters
numA : a

The first number

numB : a

The second number

Returns

The difference of the two numbers

mul

Multiplies the two arguments together.

Type Signature
(a, a) -> a where a : num
Parameters
numA : a

The first number

numB : a

The second number

Returns

The product of the two numbers

div

Divides one number by the other.

Type Signature
(a, a) -> a where a : num
Parameters
numA : a

The numerator

numB : a

The denominator

Returns

The difference of the two numbers

swap

Swaps the two elements of a tuple

Type Signature
((a,b)) -> (b,a)
Parameters
tup : (a,b)

The tuple to swap

Returns

The tuple with swapped elements

until

Yields the result of applying f until p holds.

Type Signature
((a) -> bool, (a) -> a, a) -> a
Parameters
p: (a) -> bool

The predicate

f: (a) -> a

The function to repeatedly apply

a0: a

The initial value to supply to the function

ignore

Takes a value as a parameter and ignores it.

Type Signature
(a) -> unit
clear

Clears a variable by calling that type's C++ destructor and setting the memory to zero. This function is designed to be compatible with clearing ref cells or data structures containg ref cells. This function is useful for clearing portions of data structures that hold data that should be thrown away.

Type Signature
(inout a) -> unit
Parameters
val : inout a

The memory to clear.

Returns

unit

array

Creates an array containing the given element, with the size of the array being determined by the capacity constraint on the return type.

Type Signature
(a) -> a[n]
Parameters
elem : a

The element to fill the initial array slots with.

Returns

A newly populated array.

zeros

Creates an array filled with zeros. This function is designed to work with ref types. The type and capacity of the return array is determined by constraining the return type.

Type Signature
() -> a[n]
Returns

A new array populated with zero initialized elements.

u8ToU16

Converts a uint8 to a uint16.

Type Signature
(uint8) ->uint16
Parameters
n : uint8

The number to convert

Returns

The number with converted type

u8ToU32

Converts a uint8 to a uint32.

Type Signature
(uint8) ->uint32
Parameters
n : uint8

The number to convert

Returns

The number with converted type

u8ToI8

Converts a uint8 to a int8.

Type Signature
(uint8) ->int8
Parameters
n : uint8

The number to convert

Returns

The number with converted type

u8ToI16

Converts a uint8 to a int16.

Type Signature
(uint8) ->int16
Parameters
n : uint8

The number to convert

Returns

The number with converted type

u8ToI32

Converts a uint8 to a int32.

Type Signature
(uint8) ->int32
Parameters
n : uint8

The number to convert

Returns

The number with converted type

u8ToFloat

Converts a uint8 to a float.

Type Signature
(uint8) ->float
Parameters
n : uint8

The number to convert

Returns

The number with converted type

u8ToDouble

Converts a uint8 to a double.

Type Signature
(uint8) ->double
Parameters
n : uint8

The number to convert

Returns

The number with converted type

u16ToU8

Converts a uint16 to a uint8.

Type Signature
(uint16) ->uint8
Parameters
n : uint16

The number to convert

Returns

The number with converted type

u16ToU32

Converts a uint16 to a uint32.

Type Signature
(uint16) ->uint32
Parameters
n : uint16

The number to convert

Returns

The number with converted type

u16ToI8

Converts a uint16 to a int8.

Type Signature
(uint16) ->int8
Parameters
n : uint16

The number to convert

Returns

The number with converted type

u16ToI16

Converts a uint16 to a int16.

Type Signature
(uint16) ->int16
Parameters
n : uint16

The number to convert

Returns

The number with converted type

u16ToI32

Converts a uint16 to a int32.

Type Signature
(uint16) ->int32
Parameters
n : uint16

The number to convert

Returns

The number with converted type

u16ToFloat

Converts a uint16 to a float.

Type Signature
(uint16) ->float
Parameters
n : uint16

The number to convert

Returns

The number with converted type

u16ToDouble

Converts a uint16 to a double.

Type Signature
(uint16) ->double
Parameters
n : uint16

The number to convert

Returns

The number with converted type

u32ToU8

Converts a uint32 to a uint8.

Type Signature
(uint32) ->uint8
Parameters
n : uint32

The number to convert

Returns

The number with converted type

u32ToU16

Converts a uint32 to a uint16.

Type Signature
(uint32) ->uint16
Parameters
n : uint32

The number to convert

Returns

The number with converted type

u32ToI8

Converts a uint32 to a int8.

Type Signature
(uint32) ->int8
Parameters
n : uint32

The number to convert

Returns

The number with converted type

u32ToI16

Converts a uint32 to a int16.

Type Signature
(uint32) ->int16
Parameters
n : uint32

The number to convert

Returns

The number with converted type

u32ToI32

Converts a uint32 to a int32.

Type Signature
(uint32) ->int32
Parameters
n : uint32

The number to convert

Returns

The number with converted type

u32ToFloat

Converts a uint32 to a float.

Type Signature
(uint32) ->float
Parameters
n : uint32

The number to convert

Returns

The number with converted type

u32ToDouble

Converts a uint32 to a double.

Type Signature
(uint32) ->double
Parameters
n : uint32

The number to convert

Returns

The number with converted type

i8ToU8

Converts a int8 to a uint8.

Type Signature
(int8) ->uint8
Parameters
n : int8

The number to convert

Returns

The number with converted type

i8ToU16

Converts a int8 to a uint16.

Type Signature
(int8) ->uint16
Parameters
n : int8

The number to convert

Returns

The number with converted type

i8ToU32

Converts a int8 to a uint32.

Type Signature
(int8) ->uint32
Parameters
n : int8

The number to convert

Returns

The number with converted type

i8ToI16

Converts a int8 to a int16.

Type Signature
(int8) ->int16
Parameters
n : int8

The number to convert

Returns

The number with converted type

i8ToI32

Converts a int8 to a int32.

Type Signature
(int8) ->int32
Parameters
n : int8

The number to convert

Returns

The number with converted type

i8ToFloat

Converts a int8 to a float.

Type Signature
(int8) ->float
Parameters
n : int8

The number to convert

Returns

The number with converted type

i8ToDouble

Converts a int8 to a double.

Type Signature
(int8) ->double
Parameters
n : int8

The number to convert

Returns

The number with converted type

i16ToU8

Converts a int16 to a uint8.

Type Signature
(int16) ->uint8
Parameters
n : int16

The number to convert

Returns

The number with converted type

i16ToU16

Converts a int16 to a uint16.

Type Signature
(int16) ->uint16
Parameters
n : int16

The number to convert

Returns

The number with converted type

i16ToU32

Converts a int16 to a uint32.

Type Signature
(int16) ->uint32
Parameters
n : int16

The number to convert

Returns

The number with converted type

i16ToI8

Converts a int16 to a int8.

Type Signature
(int16) ->int8
Parameters
n : int16

The number to convert

Returns

The number with converted type

i16ToI32

Converts a int16 to a int32.

Type Signature
(int16) ->int32
Parameters
n : int16

The number to convert

Returns

The number with converted type

i16ToFloat

Converts a int16 to a float.

Type Signature
(int16) ->float
Parameters
n : int16

The number to convert

Returns

The number with converted type

i16ToDouble

Converts a int16 to a double.

Type Signature
(int16) ->double
Parameters
n : int16

The number to convert

Returns

The number with converted type

i32ToU8

Converts a int32 to a uint8.

Type Signature
(int32) ->uint8
Parameters
n : int32

The number to convert

Returns

The number with converted type

i32ToU16

Converts a int32 to a uint16.

Type Signature
(int32) ->uint16
Parameters
n : int32

The number to convert

Returns

The number with converted type

i32ToU32

Converts a int32 to a uint32.

Type Signature
(int32) ->uint32
Parameters
n : int32

The number to convert

Returns

The number with converted type

i32ToI8

Converts a int32 to a int8.

Type Signature
(int32) ->int8
Parameters
n : int32

The number to convert

Returns

The number with converted type

i32ToI16

Converts a int32 to a int16.

Type Signature
(int32) ->int16
Parameters
n : int32

The number to convert

Returns

The number with converted type

i32ToFloat

Converts a int32 to a float.

Type Signature
(int32) ->float
Parameters
n : int32

The number to convert

Returns

The number with converted type

i32ToDouble

Converts a int32 to a double.

Type Signature
(int32) ->double
Parameters
n : int32

The number to convert

Returns

The number with converted type

floatToU8

Converts a float to a uint8.

Type Signature
(float) ->uint8
Parameters
n : float

The number to convert

Returns

The number with converted type

floatToU16

Converts a float to a uint16.

Type Signature
(float) ->uint16
Parameters
n : float

The number to convert

Returns

The number with converted type

floatToU32

Converts a float to a uint32.

Type Signature
(float) ->uint32
Parameters
n : float

The number to convert

Returns

The number with converted type

floatToI8

Converts a float to a int8.

Type Signature
(float) -> int8
Parameters
n : float

The number to convert

Returns

The number with converted type

floatToI16

Converts a float to a int16.

Type Signature
(float) -> int16
Parameters
n : float

The number to convert

Returns

The number with converted type

floatToI32

Converts a float to a int32.

Type Signature
(float) ->int32
Parameters
n : float

The number to convert

Returns

The number with converted type

floatToDouble

Converts a float to a double.

Type Signature
(float) ->double
Parameters
n : float

The number to convert

Returns

The number with converted type

doubleToU8

Converts a double to a uint8.

Type Signature
(double) ->uint8
Parameters
n : double

The number to convert

Returns

The number with converted type

doubleToU16

Converts a double to a uint16.

Type Signature
(double) -> uint16
Parameters
n : double

The number to convert

Returns

The number with converted type

doubleToU32

Converts a double to a uint32.

Type Signature
(double) -> uint32
Parameters
n : double

The number to convert

Returns

The number with converted type

doubleToI8

Converts a double to a int8.

Type Signature
(double) -> int8
Parameters
n : double

The number to convert

Returns

The number with converted type

doubleToI16

Converts a double to a int16.

Type Signature
(double) -> int16
Parameters
n : double

The number to convert

Returns

The number with converted type

doubleToI32

Converts a double to a int32.

Type Signature
(double) -> int32
Parameters
n : double

The number to convert

Returns

The number with converted type

doubleToFloat

Converts a double to a float.

Type Signature
(double) -> float
Parameters
n : double

The number to convert

Returns

The number with converted type

toUInt8

Converts a number to a uint8.

Type Signature
(t) -> uint8 where t : num
Parameters
n : t

The number to convert

Returns

The number with converted type

toInt8

Converts a number to a int8.

Type Signature
(t) -> int8 where t : num
Parameters
n : t

The number to convert

Returns

The number with converted type

toUInt16

Converts a number to a uint16.

Type Signature
(t) -> uint16 where t : num
Parameters
n : t

The number to convert

Returns

The number with converted type

toInt16

Converts a number to a uint16.

Type Signature
(t) -> uint16 where t : num
Parameters
n : t

The number to convert

Returns

The number with converted type

toUInt32

Converts a number to a uint32.

Type Signature
(t) -> uint32 where t : num
Parameters
n : t

The number to convert

Returns

The number with converted type

toInt32

Converts a number to a int32.

Type Signature
(t) -> int32 where t : num
Parameters
n : t

The number to convert

Returns

The number with converted type

toFloat

Converts a number to a float.

Type Signature
(t) -> float where t : num
Parameters
n : t

The number to convert

Returns

The number with converted type

toDouble

Converts a number to a double.

Type Signature
(t) -> double where t : num
Parameters
n : t

The number to convert

Returns

The number with converted type

fromUInt8

Converts a uint8 to another number type.

Type Signature
(uint8) -> t where t : num
Parameters
n : uint8

The number to convert

Returns

The number with converted type

fromInt8

Converts a int8 to another number type.

Type Signature
(int8) -> t where t : num
Parameters
n : int8

The number to convert

Returns

The number with converted type

fromUInt16

Converts a uint16 to another number type.

Type Signature
(uint16) -> t where t : num
Parameters
n : uint16

The number to convert

Returns

The number with converted type

fromInt16

Converts a int16 to another number type.

Type Signature
(int16) -> t where t : num
Parameters
n : int16

The number to convert

Returns

The number with converted type

fromUInt32

Converts a uint32 to another number type.

Type Signature
(uint32) -> t where t : num
Parameters
n : uint32

The number to convert

Returns

The number with converted type

fromInt32

Converts a int32 to another number type.

Type Signature
(int32) -> t where t : num
Parameters
n : int32

The number to convert

Returns

The number with converted type

fromFloat

Converts a float to another number type.

Type Signature
(float) -> t where t : num
Parameters
n : float

The number to convert

Returns

The number with converted type

fromDouble

Converts a double to another number type.

Type Signature
(double) -> t where t : num
Parameters
n : double

The number to convert

Returns

The number with converted type

cast

Converts a number of one type to a number of another type.

Type Signature
(a) -> b where a : num, b : num
Parameters
x : a

The number to convert

Returns

The number with converted type