Chapter 9
Modules and Errors
Organize code, propagate structured errors, and unwind resources reliably.
Pure HHY modules
import { add } from "./math.hhy"
add(20, 22) |> printV1.0 supports relative imports, named imports, aliases, exports, module caching, and cycle detection. Remote imports and third-party package installation are not included.
Structured errors
try {
read_text(path("config.json"))
|> parse_json
|> print
} catch err {
print_error(err)
exit(1)
}try/catch handles eager errors; on_error can recover lazy Flow errors. Every failure travels through one Error stage and resources unwind when scope exits.
