Functions

err core

fn (value: Any): Result

Wrap value in an error Result.Err variant.

Example

err("Not found")           // Result.Err("Not found")
err({code: 404})            // Result.Err({code: 404})

if(eq(user, null), err("User not found"), ok(user))

if-err core

fn (lazy result, handler)

If result is Err, apply function or use value. If Ok, pass through unchanged.

When the second argument is a function, it's called with the Err value. When it's a plain value, it replaces the Err (recovering to Ok).

Example

err("bad") |> if-err("default")
// Ok("default") — recovers with default value

err("bad") |> if-err(err(\`wrapped: ${%}\`))
// Err("wrapped: bad") — transforms the error

err("bad") |> if-err((e) { fetch-backup() })
// Ok(...) or Err(...) — recovery attempt

ok(42) |> if-err("default")
// Ok(42) — passes through unchanged

if-ok core

fn (lazy result, handler)

If result is Ok, apply function or use value. If Err, pass through unchanged.

When the second argument is a function, it's called with the Ok value. When it's a plain value, it replaces the Ok value.

Example

ok(1) |> if-ok(add(%, 10))
// Ok(11)

ok(1) |> if-ok("replaced")
// Ok("replaced")

err("bad") |> if-ok(add(%, 10))
// Err("bad") — passes through unchanged

is-any core

fn (value: Any): Bool

Return true if value is Any (always true).

Example

is-any("anything")  // true
is-any(null)        // true

is-bool core

fn (value: Any): Bool

Return true if value is a Bool.

Example

is-bool(true)   // true
is-bool(false)  // true
is-bool(1)      // false

is-byte core

fn (value: Any): Bool

Return true if value is a Byte.

Example

is-byte(255)  // depends on context

is-bytes core

fn (value: Any): Bool

Return true if value is a Bytes.

Example

data read-file-bytes("file.bin")
is-bytes(data)  // true

is-dec core

fn (value: Any): Bool

Return true if value is a Dec.

Example

is-dec(3.14)   // true
is-dec(42)     // false (Int, not Dec)

is-err core

fn (lazy result: Any): Bool

Return true if result is an error.

Example

is-err(Result.Err("failed"))    // true
is-err(Result.Ok(42))           // false

result fetch-data()
if-err(result, (error) { println(error) })

is-fn core

fn (value: Any): Bool

Return true if value is a Fn.

Example

is-fn(::hot::math/add)  // true
is-fn("add")            // false
is-fn(%)                 // true (lambda)

is-int core

fn (value: Any): Bool

Return true if value is an Int.

Example

is-int(42)     // true
is-int(3.14)   // false
is-int("42")   // false

is-map core

fn (value: Any): Bool

Return true if value is a Map.

Example

is-map({"a": 1})  // true
is-map({})        // true
is-map([1, 2])    // false

is-namespace core

fn (value: Any): Bool

Return true if value is a Namespace.

Example

is-namespace(Namespace("::hot::str"))  // true

is-null core

fn (value: Any): Bool

Return true if value is Null.

Example

is-null(null)    // true
is-null(false)   // false
is-null("")      // false

is-ok core

fn (lazy result: Any): Bool

Return true if result is ok (has a success value).

Example

is-ok(Result.Ok(42))            // true
is-ok(Result.Err("failed"))     // false

result safe-divide(10, 2)
if-ok(result, (value) { value })

is-result core

fn (value: Any): Bool

Return true if value is a Result type.

Example

is-result(ok(42))        // true
is-result(err("fail"))   // true
is-result(42)            // false

is-some core

fn (value: Any): Bool

Return true if value is not Null.

Example

is-some("hello")  // true
is-some(0)        // true
is-some(null)     // false

is-str core

fn (value: Any): Bool

Return true if value is a Str.

Example

is-str("hello")  // true
is-str(42)       // false

is-type core

fn (lazy val, type-ref)

Return true if value conforms to type-ref.

Example

is-type("hello", Str)  // true
is-type(42, Int)        // true
is-type([1, 2], Vec)    // true
is-type("hello", Int)  // false

// Works with pipes
my-value |> is-type(Str)

For custom types, use is-type with the type name:

Point type { x: Int, y: Int }
p Point({x: 1, y: 2})
is-type(p, Point)  // true

Works with Result types without triggering auto-unwrap:

result err("oops")
is-type(result, Result)  // true

is-var core

fn (value: Any): Bool

Return true if value is a Var.

Example

is-var(Var("::hot::str/split"))  // true

is-vec core

fn (value: Any): Bool

Return true if value is a Vec.

Example

is-vec([1, 2, 3])  // true
is-vec([])         // true
is-vec({"a": 1})   // false

ok core

fn (value: Any): Result

Wrap value in a successful Result.Ok variant.

Example

ok(42)           // Result.Ok(42)
ok("success")    // Result.Ok("success")

result ok(get-user(id))
if-ok(result, (user) { user })

untype core

fn (form: Any): Any

Transform Hot typed structures to simple Val structures by removing $type and $val metadata.

Example

// Given a typed structure
user User({"name": "Alice"})

// Remove type wrapper
untype(user)  // {"name": "Alice"}

ns alias

Alias of ::hot::type/

Type checking, conversion, and built-in type constructors.

Types

All core

All type {
    value: Vec | Map
}

Marker type for values that intentionally represent "all" produced results from a flow.

In normal Hot code you should usually not need to construct All directly. Flow result annotations such as : All<Vec> and : All<Map> are compile-time result-shape directives: they tell the compiler to collect all produced results, then erase to the underlying Vec or Map value at runtime.

Bare All is only accepted on natural collect-all flows (parallel, cond-all, and match-all). Use explicit All<Vec> or All<Map> on serial, pipe, cond, and match.

Use the All constructor only when you explicitly want to tag a collection value as "all results" for metadata, debugging, or API boundaries:

tagged All({value: [1, 2, 3]})
tagged.value  // [1, 2, 3]

For ordinary flow results, prefer annotation syntax instead:

results: All<Map> parallel {
    a fetch-a()
    b fetch-b()
}

// `results` behaves as the collected Map in normal use.

Any core

fn (value: Any): Any

Any type. Accepts any value (no type constraint).

Example

// Any is used in function signatures to accept any type
process fn (value: Any): Str { Str(value) }

Bool core

fn (value: Any): Bool

Boolean type. Convert any value to boolean (truthiness).

Example

Bool(1)       // true
Bool(0)       // false
Bool("")      // false
Bool("hi")    // true
Bool(null)    // false

Byte core

fn (value: Byte): Byte

Single byte type (0-255).

Example

b Byte(65)   // ASCII 'A'
Int(b)       // 65

Bytes core

fn (value: Bytes): Bytes

Byte array type for binary data.

Example

data Bytes([72, 105])  // "Hi" as bytes
::hot::base64/encode(data)  // "SGk="

Dec core

fn (value: Int | Dec): Dec

Decimal type (256-bit precision). Convert numeric values to decimal.

Example

Dec(42)         // 42.0
Dec(3.14159)    // 3.14159
div(Dec(1), 3)  // 0.333... (high precision)

Fn core

fn (value: Str | Fn): Fn

Function reference type.

Example

f Fn("add")    // Reference to add function
f(1, 2)         // 3

Int core

fn (value: Int | Dec): Int

Integer type. Convert numeric values to integer (truncates decimals).

Example

Int(42)      // 42
Int(3.7)     // 3
Int(-2.9)    // -2

Map core

fn (value: Any): Map

Map (object) type. Convert value to a map.

Example

Map([["a", 1], ["b", 2]])  // {"a": 1, "b": 2}

Namespace core

fn (value: Str | Namespace): Namespace

Namespace reference type.

Example

ns Namespace("::hot::str")
// Reference to the ::hot::str namespace

Null core

fn (): Null

Null type. Represents absence of a value.

Example

Null()       // null
eq(n, null)  // check for null

OnErr core

Disposition for how eligible higher-order functions (map, pmap, map-indexed, mapcat, call) handle a normal domain Result.Err.

  • OnErr.Force (default) — force the Err, stopping the operation and propagating the error to the caller (fail-fast).
  • OnErr.Preserve — keep the Err as a value according to the function's return shape. For map-shaped functions, the Err is retained as an output element. For call, the callee's Err is returned as the call result.

OnErr only applies to normal err(...) / Result.Err values. fail(), cancel(), and hard runtime errors remain exceptional and halt unless they are wrapped in an explicit containment boundary.

Passed as an optional trailing argument:

map(items, risky)                    // Force (default): fail-fast on Err
map(items, risky, OnErr.Preserve)    // preserve Err slots in the result
call(risky, [arg], OnErr.Preserve)   // return a callee Err as a value

Result core

A enum (variant union) type representing either success (Ok) or failure (Err).

Example

success Result.Ok(42)
failure Result.Err("Something went wrong")

success  // 42
failure  // "Something went wrong"

is-ok(success)   // true
is-err(failure)  // true

// Or use the convenience functions:
success ok(42)
failure err("Something went wrong")

Str core

fn (value: Any): Str

String type. Convert any value to a string.

Example

Str(42)         // "42"
Str(true)       // "true"
Str([1, 2, 3])  // "[1, 2, 3]"

Var core

fn (value: Str | Var): Var

Variable reference type.

Example

v Var("my-var")
// Reference to a variable by name

Vec core

fn (value: Any): Vec

Vector (array) type. Convert value to a vector.

Example

Vec("abc")     // ["a", "b", "c"]
Vec({"a": 1})  // [["a", 1]]