use - pannous/warp GitHub Wiki

use

use keyword includes abstract high level bundles, e.g. use graphics import keyword includes other wasp/wasm/(etc?) modules semantically include keyword includes other wasp/text files in place, as they are

require keyword is an alias for import

your own function of the same name

A function you define with the arguments of a used module's function replaces it in your program, with a warning:

use sound
play(x) := print "mine"   // warning: play replaces sound's play(tone) …; rename yours to keep both

The module's own code keeps calling its own play. A definition with another number of arguments adds to the module's word instead (clamp(x) beside math's clamp(x, low, high)), and modules the program needs without a use (beep brings sound) never warn.

folder, package and project scope

Other files are visible only on request (user, 2026-10-03; an automatic folder scope was tried and revised the same day):

use folder    // every .wasp / .warp file in the folder of this file
use package   // every file below the package folder: the nearest folder holding <folder name>.wasp
use project   // every file below the project root: the nearest folder holding .git

A name comes from the scope only when the file binds it nowhere itself (the file wins), together with the definitions that one needs and that file's own uses; files are read lazily, by name. Two files defining a used name differently is an error naming both; the same definition in both is fine. Hidden folders, packages/, target/ and nested repositories are outside every scope. Inline code (warp "use folder; area(3)") starts from the working directory. (test_use_scopes, test_folder_scope, fixtures tests/wasp/folder_*, shapes_package, project_scope)

packages

A name without a local module (name.wasp in ., include, lib, src, …) is a package of the default registry warp-packages: fetched once into packages/<name>, its <name>.warp loaded.

use colors
to_hex(mix(from_hex("#ff0000"), from_hex("#0000ff"), 0.5))   # "#800080"

The registry holds one folder per package, its versions tagged [email protected]. A folder whose manifest package.warp names a repository is a proxy for that repository: use uniscript fetches github.com/pannous/uniscript at the proxy's version and calls its prebuilt C library through the binding beside the manifest.

// uniscript/package.warp in warp-packages
repository: pannous/uniscript
version: 1.0.10
library: "c/ffi/uniscript_c"

packages.warp in warp's repository only pins or redirects: colors: 1.0.0 (the registry's tag), uniscript: "pannous/[email protected]", name: owner/repo or a git url (its default branch), and the long form {repository: owner/repo, version: 1.2.3}. On the command line it is the same program: warp use uniscript; warp fetch [name…] fetches packages without running anything.

Rust crates

use cargo regex uses a crate from crates.io: its functions are called as regex.escape("a.b") (cargo).

versions

# one of these
use uniscript version 1.0.0   // exactly this version
use uniscript from 1.0        // this one or later
use uniscript >= 1.0          // the same

A module declares its own version with a top level version 1.0.0. A version its default branch does not satisfy comes from the matching git tag (v0.1.0).

version is a soft keyword: a keyword only before a version (version 1.10, version "1.10"), otherwise a plain name (version = 2). A number with two dots or more is a version literal: 1.2.3, also as git tags write it: v1.2.3 (v2 and v1.2 stay names and member access). Versions compare part by part: 1.9 < 1.10.0, 1.2.0 == 1.2. A package used twice is loaded once; a second use asking for another version is an error naming both.

script

use script turns on script mode: the os, file, net and shell words and paths without quotes (ls ~/), see script.

⚠️ **GitHub.com Fallback** ⚠️