CLI Reference

$ hica --help

Usage: hica [OPTIONS] [COMMAND] [FILE]
The hica compiler

Options:
      --check            Check formatting without modifying the file
      --cache            Remove the stdlib cache (~/.hica/stdlib)
      --target=TARGET    Output target: koka (default) or js
  -o, --output=OUTPUT    Output binary name (build only)
      --help                 display this help and exit
      --version              output version information and exit

Commands:
  build, b               Compile a .hc file and build a binary
  run, r                 Compile and run a .hc file
  check, c               Analyse a .hc file and report errors
  fmt, f                 Format a .hc file
  clean                  Remove generated build artifacts
  test, t                Run tests in a .hc file
  new                    Create a new hica project
  init                   Initialise a hica project in the current directory
  add                    Add a dependency
  remove                 Remove a dependency
  fetch                  Fetch all dependencies
  repl                   Start an interactive REPL
  help                   Show help for a command

Commands

hica run (alias: r)

Compile and immediately run a .hc file:

hica run examples/hello.hc

hica build (alias: b)

Compile a .hc file. By default targets Koka, outputting a .kk file alongside the source:

hica build examples/arrow.hc

Use --target=js to emit JavaScript instead:

hica build --target=js examples/arrow.hc

hica check (alias: c)

Type-check a .hc file and report diagnostics without generating code:

hica check examples/hello.hc

hica clean

Remove generated build artifacts for a file:

hica clean examples/hello.hc

Remove the stdlib cache (~/.hica/stdlib/). Use this after upgrading hica to force re-extraction of the updated standard library:

hica clean --cache

hica fmt (alias: f)

Format a .hc file according to the style guide:

hica fmt examples/hello.hc

Use --check to verify formatting without modifying the file. Returns exit code 1 if changes are needed (useful in CI):

hica fmt --check examples/hello.hc

Formatting rules applied:

hica test (alias: t)

Run tests defined in a .hc file:

hica test examples/test-example.hc

Tests are written with test blocks and assertions:

fun double(n: int) : int => n * 2

test "double works" {
  assert(double(3) == 6)
  assert_eq(double(0), 0)
}

Output:

running 2 test(s)...

  ✓ double works
  ✓ basic math

2 test(s) passed

Assertions:

Function Description
assert(cond) Fails if cond is false
assert_eq(expected, actual) Fails if values differ; shows both values
assert_ne(a, b) Fails if values are equal
assert_true(cond) Fails if cond is false (descriptive message)
assert_false(cond) Fails if cond is true
assert_contains(list, elem) Fails if list does not contain element
assert_empty(list) Fails if list is not empty
assert_not_empty(list) Fails if list is empty

Exit codes: 0 if all tests pass, 1 if any test fails.

hica new

Create a new hica project with a starter file structure:

hica new my-project

hica init

Initialise a hica project in the current directory:

mkdir my-project && cd my-project
hica init

hica repl

Start an interactive Read-Eval-Print Loop:

hica repl

For history navigation, line editing, and tab completion, wrap with rlwrap:

rlwrap hica repl

Optionally preload a file to make its definitions available in the session:

hica repl lib/helpers.hc

Example session:

hica=> 1 + 2
3
hica=> _ * 10
30
hica=> let x = 5
5
hica=> x + _
35
hica=> "hello" + " world"
hello world
hica=> fun double(n) { n * 2 }
  defined: double
hica=> double(21)
42

Features:

Feature Description
_ variable Holds the result of the last evaluated expression
let bindings let x = 5 persists across the session
Function defs fun f(x) { ... } available for subsequent calls
Structs & types struct and type declarations persist
Multiline input Unbalanced {, (, [ triggers continuation (...>)
History file Input saved to ~/.hica_history
Startup file ~/.hicarc loaded automatically on start (if present)
Error recovery Type errors display cleanly; session continues

REPL commands:

Command Description
:help (:h) Show available commands
:defs List all defined functions
:reset Clear all definitions and bindings
:history Show recent input history
:load FILE Load and evaluate a .hc file
:quit (:q) Exit the REPL (also Ctrl-D)