The Errors and Types guides present Some/None/Ok/Err as built-in
constructors:
[match [Some 42]
[Some x] x
None 0]
In loon run (0.6), those forms fail with value is not callable
unless the user first declares the ADT at top level:
[type Option [Some a] None]
A missing map key also returns () (Unit), not None, so the
documented Option idiom doesn't even arise from get.
What to decide
Pick one canonical story and align everything to it:
- Option A: ship
Option and Result in the prelude so the docs
work as written, and make [get m :k] return None for a miss.
- Option B: keep the runtime as-is and rewrite every guide to show
the [type Option …] declaration and ()-as-absence, plus a
get-with-default pattern.
Acceptance criteria
- A runtime test that asserts the canonical story works as documented.
- Every code sample in
web/src/pages/guide/errors.loon and
web/src/pages/guide/types.loon runs under loon run verbatim.
Found while completing the hyperpolyglot ml column (clarkgrubb/hyperpolyglot#139).
The Errors and Types guides present
Some/None/Ok/Erras built-inconstructors:
In
loon run(0.6), those forms fail withvalue is not callableunless the user first declares the ADT at top level:
A missing map key also returns
()(Unit), notNone, so thedocumented Option idiom doesn't even arise from
get.What to decide
Pick one canonical story and align everything to it:
OptionandResultin the prelude so the docswork as written, and make
[get m :k]returnNonefor a miss.the
[type Option …]declaration and()-as-absence, plus aget-with-defaultpattern.Acceptance criteria
web/src/pages/guide/errors.loonandweb/src/pages/guide/types.loonruns underloon runverbatim.Found while completing the hyperpolyglot ml column (clarkgrubb/hyperpolyglot#139).