Skip to content
Menu
Contents

Reading the tags

pure

Same arguments, same result; touches nothing outside.

pure if arg2 is

Pure when that argument is a pure function; otherwise as impure as it is.

impure

Reads or changes something outside the program.

WasiClock

2 types2 values2 functions

The host's clocks, read in nanoseconds. realtime tells the time of day; monotonic measures how long something took, since it never goes backwards.

start = WasiClock.now(WasiClock.monotonic)?

At a glance

  • @Clock

    Which of the host's clocks to read.

  • Result

    Shorthand for [Ok(a) | Err(e)], the variant this module's fallible functions return.

  • realtime

    Wall-clock time: nanoseconds since the Unix epoch, which the host may move.

  • monotonic

    A clock that never goes backwards, from an unspecified origin: for measuring how long something took, not for telling the time.

  • now

    Nanoseconds.

  • resolution

    The clock's tick length, in nanoseconds.

Types

@Clock

type @Clock

Which of the host's clocks to read. Opaque: only this module builds one.

Result

Result(a, e) = [Ok(a) | Err(e)]

Shorthand for [Ok(a) | Err(e)], the variant this module's fallible functions return.

Values

realtime

@Clockpure

Wall-clock time: nanoseconds since the Unix epoch, which the host may move.

monotonic

@Clockpure

A clock that never goes backwards, from an unspecified origin: for measuring how long something took, not for telling the time.

Functions

now

(@Clock) -> Result(Int, [ClockUnavailable | e])impure

Nanoseconds. now(realtime) is wall-clock time since the Unix epoch; now(monotonic) counts from an unspecified origin and never goes backwards.

resolution

(@Clock) -> Result(Int, [ClockUnavailable | e])impure

The clock's tick length, in nanoseconds.

Reading the tags

pure

Same arguments, same result; touches nothing outside.

pure if arg2 is

Pure when that argument is a pure function; otherwise as impure as it is.

impure

Reads or changes something outside the program.