Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

692 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
hica logo

A safe, expression-oriented language with algebraic effects and familiar syntax.

hica is a safe, expression-oriented language with a functional style and familiar syntax.

Features include:

  • Hindley-Milner type inference
  • Algebraic effects
  • Expression-oriented design
  • No nulls or unchecked exceptions
  • Compilation to C, JavaScript, and WASM

Under the hood, hica is implemented in Koka and inherits Koka's algebraic effect system and Perceus memory management.

hica stands for Hindley-Milner Inference Compiler with Algebraic effects.

Visit hica's website for a tour of the language.

Design Goals

  • Safe by default – no null, no unhandled exceptions; errors are values (Result, Maybe).
  • Expression-oriented – everything returns a value: if, match, and blocks are all expressions.
  • Functional-first – immutability by default, higher-order functions, and pattern matching at the core.
  • Minimal ceremony – Hindley-Milner type inference means you rarely write annotations; the language gets out of your way.
  • Effect tracking – side effects (I/O, state, exceptions) are tracked by the type system, not buried in function bodies.
  • Predictable memory management – inherited from Koka's Perceus reference counting; no GC pauses, no manual allocation.
  • Familiar syntax – curly braces, let, fun, match, if, and the => expression-bodied shorthand.

Built with hica

tbdflow-ui — a desktop dashboard for tbdflow, a Trunk-Based Development CLI with thousands of downloads and a listing on trunkbaseddevelopment.com. The UI is a multi-panel ImGui app written entirely in hica.

hicurl — a modern HTTP CLI inspired by the ergonomics of HTTPie and Curlie, built entirely in hica. Features native C execution speed, zero-jq JSON response filtering, offline dry-run inspection, and environment-aware routing.

HML — hica Markup Language, a structured document and configuration format. The parser and API library are written in hica and published as a reusable package. Demonstrates multi-file libraries, recursive data types, and pattern matching on tree-shaped data.

yml2hml — a standalone CLI tool that converts YAML files to HML format. A practical example of real-world parsing, recursive data structures, and formatted output.

Concurrency & Actors

hica targets scripting, tooling, and single-threaded programs, but features first-class support for the Actor Model and cooperative concurrency via algebraic effects. With the actor keyword and the "std/actor" standard library module, you can define, spawn, and interact with stateful actors:

The standard library "std/actor" provides helpers to interact with actors:

  • send(state, msg, receive) — Sends a fire-and-forget message, discarding the returned state.
  • ask(state, msg, receive, project) — Sends a request message and projects a reply from the updated state.
  • process_messages(state, messages, receive) — Runs a fold loop to process lists/mailboxes of messages.

Cooperative Concurrency

Under the hood, actors compile to Koka's algebraic effect handlers. This enables cooperative patterns (coroutines, generators, and interleaved concurrent actors) with single-threaded schedulers without needing complex language-level async/await.

See the following examples for a deep dive:

For I/O-bound parallelism in the meantime, exec() and exec_args() let you shell out to external processes.

Install

Linux / macOS / Chromebook:

curl -fsSL https://www.hica.dev/install.sh | sh

This installs the latest release binary to ~/.local/bin. Override with HICA_INSTALL_DIR:

curl -fsSL https://www.hica.dev/install.sh | HICA_INSTALL_DIR=/usr/local/bin sh

Windows (PowerShell):

irm https://www.hica.dev/install.ps1 | iex

Build from source

Requires Koka ≥ 3.2.

git clone --recurse-submodules https://github.com/cladam/hica.git
cd hica
make release

Already cloned without --recurse-submodules? Run git submodule update --init --recursive inside the repo before building.

Why hica?

hica aims to combine:

  • the readability of Python,
  • the safety mindset of Rust,
  • the ergonomics of F#,
  • and the algebraic effects of Koka,

while keeping a familiar curly-brace syntax.

Quick Start

Create a file hello.hc:

fun main() {
  println("Hello, world")
}

Then run it:

hica run hello.hc

Other common commands:

# Compile to a binary
hica build hello.hc -o hello

# Type-check without emitting
hica check hello.hc

# Analyse code quality and FP debt
hica analyse hello.hc

# Format source
hica fmt hello.hc

Static Analysis & Quality Engine

hica includes an integrated static analyzer (hica analyse or hica a) that inspects code post-typechecking for functional anti-patterns, side-effect hygiene, and allocation bottlenecks:

# Terminal quality report with colored score summaries
hica analyse src/main.hc

# Output Markdown formatted hotspots for AI-assisted refactoring
hica analyse src/main.hc --format markdown --top 1 | genie "Refactor this hotspot"

Tracked anti-patterns include:

  • Purity & Effects: Mixed or heavy side effects (io/fsys and console) in domain functions.
  • Immutability: Imperative var declarations and for/while/loop constructs.
  • Pipelines & Allocations: Eager list transformation pipelines with >2 operations (recommends std/stream or std/xform).
  • Error Handling: Deeply nested match expressions on Maybe/Result (recommends ? operator or combinators).
  • Double Wrapping: Returning nested structures like maybe<maybe<T>> (recommends and_then/flat_map).
  • Closure & Lambda Noise: Redundant wrapper lambdas like (x) => f(x) (recommends point-free style).

Examples

Expression-bodied functions

fun double(x) => x * 2

fun main() {
  let result = double(21)
  result
}

Match expressions

fun describe(x) => match x {
  0 => "zero",
  1 => "one",
  _ => "many"
}

Lambdas

fun apply(f, x) => f(x)

fun main() {
  let sq = (n) => n * n
  apply(sq, 5)
}

Type annotations

fun add(a: int, b: int) : int => a + b

fun main() {
  let x: int = 42
  println(add(x, 8))
}

Maybe and Result types

fun safe_divide(a, b) =>
  if b == 0 { Err("division by zero") }
  else { Ok(a / b) }

fun main() {
  match safe_divide(10, 3) {
    Ok(n)  => println(n),
    Err(e) => println(e)
  }
}

FizzBuzz

fun fizzbuzz(n) =>
  if n % 15 == 0 { "fizzbuzz" }
  else if n % 3 == 0 { "fizz" }
  else if n % 5 == 0 { "buzz" }
  else { show(n) }

Running hica with a shebang!

By default, running hica transpiles to Koka, emits C, and then compiles a native binary. While this produces high-performance native executables, the C compilation step (gcc/clang) adds startup latency that can feel sluggish for lightweight scripts. Users can instead run hica code using the JS compiler for instant results (same compiler that powers the Playground and REPL) this is acheivable using a standard shebang on a Linux/Mac environment:

#!/usr/bin/env hica-js

fun main() {
    println("Running quickly with JS engine!")
}

Make the hica file executable and run it:

chmod +x file.hc
./file.hc

# Output
Running quickly with JS engine!

CLI

Command Description
build Compile a file to a binary
run Compile and run a file
check Type-check source without emitting
analyse Analyse a .hc file for FP debt and anti-patterns
fmt Format source
test Run tests in a file
new Create a new project
repl Start an interactive shell
add Add a dependency
remove Remove a dependency
fetch Fetch all dependencies
pkg Manage packages (list, info, search, tree, update)

Run hica help <command> for details on any command.

Inspirations

  • Koka – language with algebraic effects and Perceus memory management
  • Rust – syntax, safety mindset, and the match expression
  • F# – functional-first style, pipelines, and type inference ergonomics
  • C# – the => expression-bodied shorthand and query syntax
  • Python – approachable, expressive lists and comprehensions

Status

hica is under active development and moving fast — new features land regularly and contributions are welcome.

The language is usable today for experimentation and personal projects.

Compilation Pipeline

.hc source → Lex → Parse → Desugar → Type Check → Emit Koka (.kk) → Koka Compiler → C/JS/WASM

Each phase is implemented as a Koka module using algebraic effects for compiler state (diagnostics, fresh type variables, symbol scopes).

Technical Stack

Component Approach
Implementation Koka 3.x
Parsing Recursive descent with Pratt expression parsing
Type system Hindley-Milner with unification
Name resolution Declaration-aware marshalling (hc_ prefix)
CLI argument parsing klap (clap-inspired, in-tree)
Memory management Perceus (inherited from Koka target)
Backend target Koka (.kk) → C / JS / WASM via Koka
Runtime Koka standard library and runtime

Licence

Apache License 2.0 – see LICENSE.

About

hica is a high-performance, expression-oriented programming language that transpiles to Koka

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Sponsor this project

Contributors

Languages