Skip to content

Modules

Kura source files use the .kui extension. A file can share code with other files through pub and use.

Declarations are private to their file unless marked pub:

health.kui
pub type Health = { current: Int, max: Int }
pub fn percent(h: Health): Int => h.current * 100 / h.max
fn helper() => ... // private

use imports another file by its path, including the explicit .kui extension. Imports are qualified: you refer to the contents through the module’s name.

use "health.kui" // refer to it as health
use "health.kui" as hp // refer to it as hp
fn bar(h: hp.Health): Int => hp.percent(h)

The default name is the file’s base name. Unqualified imports are not supported.

The standard library root comes from an environment variable and is imported with a std/ prefix:

use "std/color.kui" as color

The v1 standard library is intentionally minimal: just enough for runtime types with memory management, loading UIs, and rendering UIs.

use also imports C headers. A .h extension says the file is C. See C Interop.

By convention, a .kui file describes one UI or one UI element. A game HUD might be split into a health bar, a map and an inventory bar, each its own file with its own view.