Skip to main content

Type

Library of functions that apply to types.

Functions

Cast

Casts an expression to a specific type.

Syntax:
Type.Cast(type: type, expression: anything)
Parameters
  • type: The type to cast to.

  • expression: The expression to cast.

Returns
  • The casted expression.
Example:
Type.Cast(type double, 1)
// Result:
// 1.0

Match

Processes a value depending of its potential types

Syntax:
Type.Match(v: any, f: function ...)
Parameters
  • v: The value to process.

  • f: A function that applies to one of the value's potential types.

Returns
  • The result of the function that applies to the value's type.
Example:
Type.Match(v,
x: int -> x, // returns an int
l: list(int) -> List.Sum(l) // returns an int
)

Details

Type.Match takes as a parameter an or-type of type X or Y or Z, and a set of functions that apply to X, Y or Z. All functions should return results of compatible types.

caution

Functions should not be null or an error. If any of the functions is null or an error, Type.Match evaluates to null/error.