Overview #

Quest includes a carefully curated standard library with modules for common tasks.

Importing Modules #

Use the use statement to import modules:

use "std/math" as math
puts(math.pi)  # 3.141592653589793

Available Modules #

Mathematics and Numerics #

  • math - Mathematical functions (sin, cos, sqrt, etc.) and constants (pi, e)
  • ndarray - N-dimensional arrays for numerical computing and linear algebra

String Processing #

  • str - String manipulation utilities
  • regex - Regular expression pattern matching and text manipulation

Data Encoding #

  • json - JSON encoding and decoding (std/encoding/json)
  • encoding - Base64 encoding and decoding (std/encoding/b64)
  • compress - Data compression (gzip, bzip2, deflate, zlib)

Data Types #

  • uuid - Universally Unique Identifiers (UUIDs) for globally unique IDs

Database #

  • database - Database connectivity for SQLite, PostgreSQL, and MySQL

Cryptography #

  • hash - Cryptographic hash functions (MD5, SHA1, SHA256, SHA512)
  • crypto - HMAC and other cryptographic functions
  • rand - Random number generation (secure, fast, seeded)

Input/Output #

  • io - File and stream I/O operations
  • serial - Serial port communication for Arduino, microcontrollers, and devices

System Integration #

  • sys - System information and command-line arguments
  • os - Operating system interfaces
  • process - External command execution and subprocess management
  • time - Date and time operations
  • conf - Module configuration system with schema validation

Web and HTML #

  • html/templates - HTML templating with Tera (Jinja2-like syntax)
  • http - HTTP client for making web requests and REST APIs
  • urlparse - URL parsing and manipulation

Terminal #

  • term - Terminal colors and text formatting

Development #

  • test - Unit testing framework

Module Usage Patterns #

Basic Import #

use "std/math" as math
let result = math.sqrt(16)  # 4

Multiple Imports #

use "std/encoding/json" as json
use "std/io" as io

let data = {"name": "Quest", "version": "1.0"}
let text = json.stringify(data)
io.write("data.json", text)

Module Members #

Modules can contain:

  • Functions: Callable operations
  • Constants: Read-only values (like math.pi)

Access members using dot notation:

use "std/math" as m

puts(m.pi)           # Constant
puts(m.sin(m.pi))    # Function call

Creating Your Own Modules #

Quest modules are simply .q files that export values:

# mymodule.q
let version = "1.0"

fun greet(name)
    "Hello, " .. name
end

# Export by having them in scope

Import your module:

use "mymodule" as mine
puts(mine.greet("World"))

See Modules for more details on creating and organizing modules.