$ fmt
= 0
$ check
= 0
10 definitions, 0 programs
$ show w.Capability
= 0
-- A capability: three fields, which a file keeps on one line.
type Capability = rec handle int, kind buffer 64 byte, rights buffer 64 byte
$ show w.Capability 40
= 0
-- A capability: three fields, which a file keeps on one line.
type Capability = rec
  handle int,
  kind buffer 64 byte,
  rights buffer 64 byte
$ show w.Capability 80
= 0
-- A capability: three fields, which a file keeps on one line.
type Capability = rec handle int, kind buffer 64 byte, rights buffer 64 byte
$ show w.Shape 60
= 0
-- A shape.
type Shape = enum
  Dot |
  Circle radius int |
  Rect width int, height int
$ show w.area
= 0
-- The area of a shape, scaled and moved.
fn area shape Shape, scale int, offset int -> int = match shape {
  Dot => offset
  Circle radius => radius * radius * scale + offset
  Rect width height => width * height * scale + offset
}

-- A shape.
type w.Shape = enum Dot | Circle radius int | Rect width int, height int
$ show w.area 30
= 0
-- The area of a shape, scaled and moved.
fn area shape Shape,
    scale int,
    offset int -> int = match shape {
  Dot => offset
  Circle radius =>
    radius * radius * scale +
      offset
  Rect width height =>
    width * height * scale +
      offset
}

-- A shape.
type w.Shape = enum
  Dot |
  Circle radius int |
  Rect width int, height int
$ show w.area 60
= 0
-- The area of a shape, scaled and moved.
fn area shape Shape,
    scale int,
    offset int -> int = match shape {
  Dot => offset
  Circle radius => radius * radius * scale + offset
  Rect width height => width * height * scale + offset
}

-- A shape.
type w.Shape = enum
  Dot |
  Circle radius int |
  Rect width int, height int
$ show w.make 30
= 0
fn make id int,
    weight int -> Item = Item {
  id = id,
  weight = weight + BASE,
}

type w.Item = rec
  id int,
  weight int

-- One for all.
const BASE int = 1
$ show w.make 60
= 0
fn make id int, weight int -> Item = Item {
  id = id,
  weight = weight + BASE,
}

type w.Item = rec id int, weight int

-- One for all.
const BASE int = 1
$ show w.total 30
= 0
-- A sum of a, b and c, or 0 when it is out of range.
fn total a int,
    b int,
    c int -> int = {
  let sum =
    a * 1000 + b * 100 +
      c * 10 + a * b * c
  if sum > 1000000 &&
    sum < 2000000 ||
    sum == 42 then
    return sum else return 0
}
$ show w.total 60
= 0
-- A sum of a, b and c, or 0 when it is out of range.
fn total a int, b int, c int -> int = {
  let sum = a * 1000 + b * 100 + c * 10 + a * b * c
  if sum > 1000000 && sum < 2000000 || sum == 42 then
    return sum else return 0
}
$ show w.Wide 60
= 0
-- A variant with more fields than a narrow line holds.
type Wide = enum
  Small |
  Big alpha int, beta int, gamma int, delta int
$ show w.Wide 40
= 0
-- A variant with more fields than a narrow line holds.
type Wide = enum
  Small |
  Big alpha int,
    beta int,
    gamma int,
    delta int
$ show w.first 50
= 0
-- A construction among a call's arguments, not the last.
fn first -> int =
  pick Item { id = 1, weight = 2000 } 100

fn w.pick item Item, limit int -> int
type w.Item = rec id int, weight int
$ show w.first 40
= 0
-- A construction among a call's arguments, not the last.
fn first -> int =
  pick Item {
    id = 1,
    weight = 2000,
  } 100

fn w.pick item Item, limit int -> int
type w.Item = rec id int, weight int
$ show w.Capability 19
= 2
lang: a width is 20 to 400 columns, not 19
$ show w.Capability 401
= 2
lang: a width is 20 to 400 columns, not 401
$ show w.Capability wide
= 2
lang: a width is 20 to 400 columns, not wide
