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

1 type2 values2 functions

The host's clocks, read in nanoseconds, over wasi:clocks. realtime tells the time of day; monotonic measures how long something took, since it never goes backwards. The wasip1 package's WasiClock has the same names, but its now and resolution answer a Result, because a preview 1 host can refuse a clock; a WASI 0.2 host cannot, so these answer the number itself.

start = WasiClock.now(WasiClock.monotonic)

At a glance

  • @Clock

    Which of the host's clocks to read.

  • 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.

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) -> Intimpure

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

resolution

(@Clock) -> Intimpure

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.