Language introspection and function invocation utilities.

Functions

call core

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

Call function f with args (default empty vec). Supports both single-argument and no-argument forms.

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(maybe-fetch, [id], OnErr.Preserve)
if-err(result, (e) { fallback(e) })

functions-in-namespace core

fn (namespace: Namespace): Vec

Return all functions defined in namespace.

Example

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

namespaces core

fn (): Vec

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.

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.

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: user.id}],
    schedule: "in 10 minutes"
})

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

Returns the schedule_id which can be used to cancel.

event hot:schedule:new