$ check
= 0
36 definitions, 1 programs
$ fmt
= 0
$ cc app.main
= 0
$ list
= 0
-- A prelude that declares the builtins (lang.md 2, "The ABI, generated"):
-- each a fn without a body, held to the compiler's signature, and every
-- one that has a signature, since a prelude that declares one declares all.

type Duration = int
const ms Duration = 1000000
type MonoTime = point Duration

-- The builtins

fn write bytes str  -- Writes bytes to the console.
fn exit code int
fn monotime -> MonoTime  -- The monotonic clock.
fn walltime -> int
fn randombytes dst view byte -> bool
fn nop -> int  -- Does nothing and gives 0.
fn cpuTicks -> int
fn cpuHz -> int
fn memcreate size int -> opt cap Memory
fn memsize m cap Memory -> int
fn memread m cap Memory, offset int, dst view byte -> bool
fn memwrite m cap Memory, offset int, src str -> bool
fn map m cap Memory -> opt view byte
fn sendraw ch cap Channel, bytes str, gift opt cap Any -> bool
fn encode value X -> arr byte  -- A signature's own names for its type variable and parameters.
fn store bytes view byte, off int, v T
fn yield
fn recordmount space cap Space -> int
fn recordstage size int -> int
fn recordedit slot int, off int, bytes str -> int
fn recordadopt slot int, size int -> int
fn recordwrite off int, bytes str -> int
fn recordread key str, off int, dst view byte -> int
fn recordhash key str, off int, size int -> int, arr 32 byte
fn recordhashstep slot int, key str, off int, size int, state view byte -> int
fn recordfinish key str -> int
fn recordpublish key str -> int
fn sha256 bytes str -> arr 32 byte
fn send ch wchan T, v T -> bool
fn recv ch rchan T -> opt T

namespace app  -- A program under a prelude that declares the builtins.
namespace lib
$ show monotime
= 0
-- The monotonic clock.
fn monotime -> MonoTime

type MonoTime = point Duration
$ show nop
= 0
-- Does nothing and gives 0.
fn nop -> int
$ show app.main
= 0
fn main = {
  let start = monotime ()
  let waited = monotime () - start
  write "x"
  assert nop () == 7 && lib.zero () == 0
  let tx, rx = channel int 1
  assert send tx 1
  if let v = recv rx then exit (v + waited / 1ms)
}

-- The monotonic clock.
fn monotime -> MonoTime

-- Writes bytes to the console. A second sentence, which a listing leaves
-- out.
fn write bytes str

-- This namespace's own nop, which the call in main names.
fn app.nop -> int

-- The builtin nop, which app's nop does not hide here.
fn lib.zero -> int

fn send ch wchan T, v T -> bool
fn recv ch rchan T -> opt T
fn exit code int
const ms Duration = 1000000
$ find monotime
= 0
fn monotime -> MonoTime
  app.main:1
  app.main:2
$ find nop
= 0
fn app.nop -> int
  app.main:4
fn nop -> int
  lib.zero:1
$ hash monotime
= 0
6e24b28312e47cc82cf63bc97a73d64594f7aa8bd6718d56e23027f56b2837a9 - monotime
$ build monotime
= 1
E008 monotime:0 Type a program's root is a function with no parameters, no result and a body
$ assets monotime
= 1
E008 monotime:0 Type a program's root is a function with no parameters, no result and a body
