All examples
Language

Typed recoverable outcomes

Return explicit success/error alternatives from functions and inspect strict native conversion errors.

Download .aner source
result_basic.aner
fn divide(numerator: Float64, denominator: Float64) -> Result<Float64, String> {
    if denominator == 0.0 {
        return Result.err<Float64, String>(error: "denominator is zero")
    }
    return Result.ok<Float64, String>(value: numerator / denominator)
}
let outcome = divide(6.0, 2.0)
if outcome.is_ok() {
    print(outcome.unwrap())
} else {
    print(outcome.unwrap_err())
}
let failed = divide(6.0, 0.0)
print(failed.is_err())
print(failed.unwrap_err())
print(failed.unwrap_or(default: -1.0))
print(type(outcome))

let parsed = Date.try_parse("2026-02-30")
if parsed.is_err() {
    print(parsed.unwrap_err())
}
let decoded = Bytes.from_hex("ff").try_decode_utf8()
print(decoded.is_err())

Make it your experiment.

With Aner installed, save this program as examples/result_basic.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/result_basic.aner
aner run examples/result_basic.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use the compatible native Aner development engine with import free temporal, binary, Range, Optional and Result values, and VS Code extension 0.1.37 or newer. No import is required. Calendar values use Gregorian and explicit fixed offset contracts; Bytes uses strict explicit text encoding; Range is lazy; outcome payload access is checked. See each separate native value reference for exact ownership, resource limits and time/space complexity.

Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner