Language introspection and function invocation utilities.

Functions

apply core

fn (args: Vec<Any>, f: Fn): Any
fn (args: Vec<Any>, f: Fn, on-err: OnErr): Any

Call f with the items of args as its arguments. This is call with the data first, as map and reduce take it, so it fits a pipe. Clojure's apply takes the function first. To call a function you can name, spread is shorter and keeps its return type: add(...xs).

A normal domain Err returned by the callee is forced. Pass OnErr.Preserve to return the Err as the result instead, as with call.

Example

apply([1, 2, 3], add)              // 6
[1, 2, 3] |> apply(add)            // 6
map([[1, 2], [3, 4]], apply(%, add))  // [3, 7]

// Preserve a recoverable domain Err as a value
result apply([10, 0], div, OnErr.Preserve)

call core

fn (f: Fn, args: Vec<Any>): Any
fn (f: Fn, args: Vec<Any>, on-err: OnErr): Any
fn (f: Fn): Any

Call function f with args (default empty vec). Supports both single-argument and no-argument forms. apply is the same call with the data first, for pipes.

By default, a normal domain Err returned by the callee is forced. Pass OnErr.Preserve to return the Err as the call result instead. fail(), cancel(), and hard runtime errors still halt unless explicitly contained.

Example

// Call a function by reference
add-fn ::hot::math/add
call(add-fn, [1, 2])  // 3

// Call with no arguments
call(::hot::math/rand)  // 0.7234...

// Preserve a recoverable domain Err as a value
result call(div, [10, 0], OnErr.Preserve)
if-err(result, (e) { println(e) })

functions-in-namespace core

fn (namespace: Namespace): Vec<Fn>

Return all functions defined in namespace.

Example

fns functions-in-namespace(Namespace("::hot::math"))
// [add, sub, mul, div, ...]

namespaces core

fn (): Vec<Namespace>

Return all loaded namespaces.

Example

all-ns namespaces()
// [::hot::coll, ::hot::str, ::myapp::users, ...]

resolve core

fn (function-str: Str): Fn

Resolve a fully-qualified function name string to a Fn value.

Example

add-fn resolve("::hot::math/add")
call(add-fn, [1, 2])  // 3

call-event-handler event

fn (event: Map): Any

Event handler: call a function specified in event data.

The once: true flag ensures this handler runs only once per event, even when multiple projects are deployed in the same environment.

Example

// The handler calls ::myapp::orders/process({order_id: "123"})
send("hot:call", {fn: "::myapp::orders/process", args: [{order_id: "123"}]})
event hot:call

schedule-cancel-event-handler event

fn (event: Map): Bool

Event handler: cancel a scheduled call (one-time or recurring).

The once: true flag ensures this handler runs only once per event, even when multiple projects are deployed in the same environment.

Example

// Cancel by schedule-id
send("hot:schedule:cancel", {schedule-id: "01234567-..."})

// Cancel by function name (cancels all schedules for this function)
send("hot:schedule:cancel", {fn: "::myapp::jobs/heavy-process"})

Returns true if schedule was found and cancelled.

event hot:schedule:cancel

schedule-event-handler event

fn (event: Map): Any

Event handler: execute scheduled function from event data.

The once: true flag ensures this handler runs only once per event, even when multiple projects are deployed in the same environment.

Example

// The handler calls ::myapp::reports/daily("2026-10-14")
send("hot:schedule", {fn: "::myapp::reports/daily", args: ["2026-10-14"]})
event hot:schedule

schedule-new-event-handler event

fn (event: Map): Str

Event handler: create a new schedule (one-time or recurring).

The once: true flag ensures this handler runs only once per event, even when multiple projects are deployed in the same environment.

Supported schedule formats

  • ISO datetime: "2024-01-15T10:30:00Z"
  • Duration: "10 minutes", "2h", "1 day 3 hours"
  • Natural: "in 10 minutes", "2 hours from now"
  • Cron: "0 30 9 * * MON", "@daily"
  • English: "every day at 9am", "every Monday at 2 PM"

Example

// Schedule for specific time
send("hot:schedule:new", {
    fn: "::myapp::orders/process",
    args: [{order_id: "123"}],
    schedule: "2024-01-15T10:30:00Z"
})

// Schedule for 10 minutes from now
send("hot:schedule:new", {
    fn: "::myapp::reminders/send",
    args: [{user_id: "u-1"}],
    schedule: "in 10 minutes"
})

// Create a recurring schedule dynamically
send("hot:schedule:new", {
    fn: "::myapp::reports/daily",
    args: [],
    schedule: "every day at 9am"
})

The handler's run returns the schedule ID. send returns an EventInfo, not that ID, so the sending code cannot read it: take it from the run's result in the Hot App or the API, or cancel by fn.

event hot:schedule:new