EXAMPLES · v1.0.4

Learn yamoon by reading it.

Small, complete .hyml files covering the language. To compile any of these for real and see the generated Hoon, open the playground.

EXAMPLE 01

Functions

A function declares its input, its output, and the expression it returns.

Loading editor…
EXAMPLE 02

Generics

New in 1.0.3: type_args declares polymorphic parameters. The compiler infers T at each call and enforces it.

Loading editor…
EXAMPLE 03

Native bindings & raw Hoon

Import existing Hoon libraries, describe them with native:, and drop to raw Hoon with hoon: when you need it.

Loading editor…
EXAMPLE 04

Records & unions

Group fields into a record, or list alternatives with a union and pull them apart with match.

Loading editor…
EXAMPLE 05

Lists, maps & sets

Collections are functions that map to Hoon's list, by, and in engines.

Loading editor…
EXAMPLE 06

Macros

Define a shape once and call it like a function. It expands before Hoon is generated.

Loading editor…
EXAMPLE 07

Scenario tests

New in 1.0.3: drive a Gall agent through a journey of pokes and waits; yamoon threads the state and checks it.

Loading editor…
EXAMPLE 08

A Gall agent

Set target: gall to unlock agent state, pokes, and scries.

Loading editor…