HQL Language Manual

This manual covers installation, CLI usage, and key workflows. For complete syntax, see HQL-SYNTAX.md.


Table of Contents


Installation

Build from Source

See the build guide for build and install steps. If you do not install system-wide, use ./hlvm in the examples below.


Getting Started

Hello World

Create hello.hql:

(print "Hello, World!")

Run it:

./hlvm run hello.hql

Interactive REPL

./hlvm repl
hlvm> (+ 1 2 3)
6
hlvm> (let name "HQL")
hlvm> (print "Hello," name)
Hello, HQL

Quick Syntax Overview

// Variables
(let x 10)            // Block-scoped mutable
(const PI 3.14159)    // Immutable
(var count 0)         // Function-scoped mutable

// Functions
(fn add [a b] (+ a b))
(fn greet [name = "World"]
  (print "Hello," name))

// Type annotations (no space after colon!)
(fn add [a:number b:number] :number
  (+ a b))

// Data structures
(let nums [1 2 3])
(let person {name: "Alice" age: 30})

// Control flow
(if (> x 10) "big" "small")
(cond
  ((< x 0) "negative")
  ((=== x 0) "zero")
  (else "positive"))

See HQL-SYNTAX.md for complete syntax reference.


CLI Reference

Commands

CommandDescription
hlvm run <file>Execute HQL file
hlvm run '<expr>'Evaluate expression
hlvm replStart interactive REPL
hlvm compile <file>Compile to JavaScript
hlvm initInitialize new project
hlvm upgradeShow upgrade instructions

Compile Options

hlvm compile app.hql                     # Dev build
hlvm compile app.hql --release           # Production build
hlvm compile app.hql --target native     # Native binary
hlvm compile app.hql -o myapp.js         # Custom output

Global Options

OptionDescription
--helpShow help
--versionShow version
--verboseDetailed logging
--debugDebug information

Standard Library

See Standard Library Reference for complete documentation.

Sequence Operations

(first [1 2 3])           // 1
(rest [1 2 3])            // [2 3]
(take 2 [1 2 3 4])        // [1 2]
(drop 2 [1 2 3 4])        // [3 4]
(nth [1 2 3] 1)           // 2

Transformations

// map and filter return lazy sequences (print as lists like Clojure)
(map (fn [x] (* x 2)) [1 2 3])     // (2 4 6)
(filter (fn [x] (> x 2)) [1 2 3])  // (3)

// Use vec to get a concrete array
(vec (map (fn [x] (* x 2)) [1 2 3])) // [2 4 6]

// reduce consumes the sequence
(reduce + 0 [1 2 3 4])             // 10

Map Operations

(assoc {a: 1} "b" 2)      // {a: 1, b: 2}
(dissoc {a: 1, b: 2} "a") // {b: 2}
(keys {a: 1, b: 2})       // ["a", "b"]
(vals {a: 1, b: 2})       // [1, 2]

Type Predicates

(isNull x)            // x === null
(isUndefined x)       // x === undefined
(isNil x)             // x == null
(isString x)          // typeof x === "string"
(isNumber x)          // typeof x === "number"
(isArray x)           // Array.isArray(x)

Further Reading

DocumentDescription
HQL-SYNTAX.mdComplete syntax reference (definitive)
TYPE-SYSTEM.mdTypeScript type system coverage
api/Complete API documentation
api/stdlib.mdBuilt-in functions
GUIDE.mdLearning guide from beginner to advanced