--- id: toplevel title: Toplevel description: Available functions at the top level hide_table_of_contents: true --- import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; These functions are available without any needed prefix. function is_nat: int -> option(nat) val is_nat: int -> nat option let is_nat: int => option(nat) Convert an `int` to a `nat` if possible. function abs: int -> nat val abs: int -> nat let abs: int => nat Cast an `int` to `nat`. function int: nat -> int val int: nat -> int let int: nat => int Cast an `nat` to `int`. const unit: unit val unit: unit let (): unit A helper to create a unit. function failwith : string -> unit val failwith : string -> unit let failwith : string => unit Cause the contract to fail with an error message. > ⚠ Using this currently requires in general a type annotation on the > `failwith` call. function assert : bool -> unit val assert : bool -> unit let assert : bool => unit Check if a certain condition has been met. If not the contract will fail.