$ check
= 0
14 definitions, 1 programs
$ fmt
= 0
$ list
= 0
-- The root of the reading commands' tree: what every namespace sees. A
-- second sentence, which a listing leaves out.

fn base -> int  -- One for all.

namespace app  -- An app.
namespace lib  -- A library.
namespace only
$ list lib
= 0
-- A library. It has a namespace under it,
-- lib.deep.

const FACTOR int = 3
type Shape = enum Circle r int | Dot  -- A shape!
global count int

-- Scaling
--
-- A heading's second paragraph, which a listing keeps.

fn scale x int -> int  -- Scales x by the factor, a sentence that takes two lines.
type Wide = rec a int, b int, c int, d Shape  -- A record of more than three fields, which a file breaks and a listing does not
fn widen s Shape -> Wide

namespace lib.deep  -- Under lib: scale is lib.scale.
$ list only
= 0
namespace only.leaf
$ list only.leaf
= 0
-- A heading at the top of a namespace that has no comment.

fn scale x int -> int  -- Its own scale, which a find of scale tells from lib's.

--

fn sample -> int  -- Indented in its comment.
$ list app
= 0
-- An app.

fn helper -> int  -- A helper that the name helper in a comment and a local named helper do not refer to.
global total int
fn area s lib.Shape -> int
fn main  -- The program.
$ list lib.nosuch
= 2
lang: no namespace named lib.nosuch
$ list lib.
= 2
lang: no namespace named lib.
$ show app.main
= 0
-- The program. The helper of this comment is no reference, and the local
-- named helper in it is none.
fn main = {
  total = lib.scale (helper ()) + lib.deep.twice 1
  let n = {
    let helper = 3
    helper + 1
  }
  let w = lib.widen lib.Circle { 2 }
  exit (total + n + w.a + area w.d + base ())
}

global app.total int

-- Scales x by the factor, a sentence that
-- takes two lines. And one more.
fn lib.scale x int -> int

-- A helper that the name helper in a comment and a local named helper do
-- not refer to. Is that so?
fn app.helper -> int

fn lib.deep.twice x int -> int
fn lib.widen s Shape -> Wide

-- A shape! Its second sentence.
type lib.Shape = enum Circle r int | Dot

fn app.area s lib.Shape -> int

-- One for all.
fn base -> int
$ show lib.widen
= 0
fn widen s Shape -> Wide = Wide { a = 1, b = 2, c = scale 3, d = s }

-- A shape! Its second sentence.
type lib.Shape = enum Circle r int | Dot

-- A record of more than three fields, which a file breaks and a listing
-- does not
type lib.Wide = rec a int, b int, c int, d Shape

-- Scales x by the factor, a sentence that
-- takes two lines. And one more.
fn lib.scale x int -> int
$ show lib.deep.twice
= 0
fn twice x int -> int = scale (scale x)

-- Scales x by the factor, a sentence that
-- takes two lines. And one more.
fn lib.scale x int -> int
$ show lib.Circle
= 2
lang: no definition named lib.Circle
$ find scale
= 0
fn lib.scale x int -> int
  app.total:1
  app.main:1
  lib.widen:1
  lib.deep.twice:1
fn only.leaf.scale x int -> int
  only.leaf.sample:1
$ find leaf.scale
= 0
fn only.leaf.scale x int -> int
  only.leaf.sample:1
$ find lib.Shape
= 0
type lib.Shape = enum Circle r int | Dot
  app.area:0
  app.area:1
  app.main:3
  lib.Wide:0
  lib.widen:0
$ find Circle
= 0
variant lib.Circle of lib.Shape
  app.area:1
  app.main:3
$ find helper
= 0
fn app.helper -> int
  app.main:1
$ find base
= 0
fn base -> int
  app.main:4
$ find nosuch
= 2
lang: no definition named nosuch
