Host

:= {
    frame_count : U64,
    timestamp_nanos : U64,
    frame_time : F32,
    screen : { width : I32, height : I32 },
    keys : List(U8),
    text_input : List(U32),
    gamepads : Snapshot,
    mouse : State,
}

Host module - provides platform state and system effects

key_up : Host, KeyboardKey -> Bool

Check whether a key is currently up. Receiver form: host.key_up(KeyW).

key_pressed : Host, KeyboardKey -> Bool

Check whether a key was pressed this frame. Receiver form: host.key_pressed(KeyW). Static Keys.key_pressed(host, KeyW) remains available; combine singular queries with or when checking alternatives.

key_released : Host, KeyboardKey -> Bool

Check whether a key was released this frame. Receiver form: host.key_released(KeyW). Static Keys.key_released(host, KeyW) remains.

gamepad : Host, GamepadId -> [Connected(ConnectedPad), Disconnected]

Resolve a gamepad slot in this frame's sampled snapshot. The returned pad is snapshot-scoped; query it now rather than retaining it in the model.

exit! : Host, I32 => {  }

Exit the application with the given exit code. The exit happens after the current frame completes to allow proper cleanup.

read_env! : Host, Str => Try(Str, [NotFound, ..])

Read an environment variable by key. Returns Ok with the value if found, or Err NotFound if not set.

read_file! : Host, Str => Try(Str, [NotFound, ReadFailed, ..])

Read a UTF-8 text file from disk. Receiver form: host.read_file!(path).

random_i32! : Host, I32, I32 => I32

Get a random integer in the range [min, max] (both endpoints included). The generator is seeded once at startup, so sequences differ between runs. Derive other ranges/floats from this, e.g. a random direction with if host.random_i32!(0, 1) == 0 -1 else 1.

set_screen_size! : Host, { width : I32, height : I32 } => Try({  }, [InvalidSize, NotSupported, ..])

Set the window/screen size to positive integer dimensions. Returns Err NotSupported on platforms that don't support window resizing (e.g., web). Receiver form: host.set_screen_size!(size).

set_target_fps! : Host, I32 => {  }

Set raylib's CPU-side frame-rate cap. Values at or below zero render uncapped. This neither selects a software renderer nor controls VSync. Note: On web/WASM, this has no effect as the browser controls frame timing. Receiver form: host.set_target_fps!(fps).

set_cursor_mode! : Host, CursorMode => {  }

Apply cursor visibility/capture atomically through one tagged operation.

CursorMode : [Visible, Hidden, Locked]

Cursor visibility and capture policy applied with host.set_cursor_mode!.