Records, variants, enums and flags.
Types
record point
A point on a plane.
x:f64Across.
y:f64Down.
record empty-ish
only:bool
variant shape
A shape, with or without a payload.
enum direction
The cardinal directions.
northeastsouthwest
flags permissions
A file's permissions.
readwriteexecute
Functions
area: func(s: shape) -> f64
A block comment documents too.
allowed: func(have: permissions, want: permissions) -> bool
WIT
/// Records, variants, enums and flags.
interface shapes {
use containers.{pair, maybe};
/// A point on a plane.
record point {
/// Across.
x: f64,
/// Down.
y: f64,
}
/// A record of other types.
record labeled {
label: maybe,
at: point,
tags: list<string>,
pair: pair,
}
record empty-ish {
only: bool,
}
/// A shape, with or without a payload.
variant shape {
/// A point has no size.
dot,
circle(f64),
rectangle(tuple<point, point>),
polygon(list<point>),
}
/// The cardinal directions.
enum direction {
north,
east,
south,
west,
}
/// A file's permissions.
flags permissions {
read,
write,
execute,
}
/// An alias of an alias.
type heading = direction;
/// A block comment documents too.
area: func(s: shape) -> f64;
/// A keyword as a name, escaped with `%`.
turn: func(%from: direction, quarter-turns: s8) -> direction;
allowed: func(have: permissions, want: permissions) -> bool;
}