.nib std
nib 0.3.1-pre

Pre-release documentation. This describes nib 0.3.1-pre, which is on main and has no release yet: what it documents beyond 0.3.0 may change before it ships.

module

Failure

A raise held as a value — what a rescue f => arm binds — typed by the tags it can be, opened by match, and raised again with raise f.

A rescue arm written with a lowercase name catches whatever the arms above it did not, and keeps it: the name is bound to the raise itself, its tag and its payload. Its type is Failure<T1, …>, the row of tags it can still be, so a later match names those tags (with their payloads typed by their declarations), a name binds whatever is left, and the compiler refuses an arm for a tag the failure cannot be. raise f raises it again, and charges only the tags it can be.

Failure.tag(f) answers the tag's name and Failure.message(f) its message: the payload's String, or its last piece when it has several.

try "{Vec.get(#[1], 5)}" rescue f => Failure.message(f) end
index 5 is outside a Vec of 1

A Switch.defer cleanup is handed the failure that ended its switch, if one did.