A concatenative, stack-based programming language with static typing, tail call optimization, and CSP-style concurrency.
Compiler: Functional (compiles .seq source to native executables via LLVM IR)
Runtime: Strands (green threads), channels, TCP I/O, arena allocation
Tail Call Optimization: Guaranteed TCO for recursive functions via LLVM musttail
Type System: Row polymorphic stack effects with type inference
Standard Library: JSON, YAML, HTTP, math utilities
Editor Support: LSP server with diagnostics and completions
See docs/ROADMAP.md for the development plan.
clang is required to compile Seq programs (used to compile LLVM IR to native executables):
- macOS:
xcode-select --install - Ubuntu/Debian:
apt install clang - Fedora:
dnf install clang
cargo install seq-compiler # installs seqc
cargo install seq-lsp # installs seq-lsp (optional, for editor support)cargo build --releaseCompile and run a program:
seqc examples/hello-world.seq --output /tmp/hello
/tmp/helloCheck version:
seqc --versionRun tests:
cargo test --allCore Language:
- Stack operations:
dup,drop,swap,over,rot,nip,tuck,pick - Arithmetic:
+,-,*,/with overflow checking - Bitwise:
band,bor,bxor,bnot,shl,shr,popcount,clz,ctz - Numeric literals: decimal, hex (
0xFF), binary (0b1010) - Comparisons:
=,<,>,<=,>=,<> - Conditionals:
if/else/then - Quotations: First-class functions with
call,times,while,until - Closures: Captured environments with type-driven inference
Tail Call Optimization:
- Guaranteed TCO via LLVM's
musttailandtailcccalling convention - Recursive functions execute in constant stack space (100k+ calls tested)
- Mutual recursion fully supported
- Quotation calls (
callword) are TCO-eligible - Closures use Arc-based environments for efficient tail calls
I/O and Strings:
- Console:
write_line,read_line - Files:
file-read,file-write,file-exists? - Strings:
concat,split,trim,length,contains,starts-with,to-upper,to-lower
Concurrency:
- Strands:
spawn(green threads) - Channels:
make-channel,send,receive,close-channel - TCP:
tcp-listen,tcp-accept,tcp-read,tcp-write,tcp-close
Standard Library (via include std:module):
std:json- JSON parsing and serializationstd:yaml- YAML parsing and serializationstd:http- HTTP request/response utilitiesstd:math- Mathematical functionsstd:stack-utils- Stack manipulation utilities
See examples/ for working programs:
hello-world.seq- Basic I/Orecursion/fibonacci.seq,recursion/factorial.seq- Recursionjson/json_tree.seq- JSON parsing with the stdlibhttp/*.seq- HTTP routing and TCP servershackers-delight/*.seq- Bit manipulation puzzles (rightmost bits, power of 2, popcount, branchless ops)
The seq-lsp language server provides IDE features in your editor.
Install:
cargo install seq-lspNeovim: Use patch-seq.nvim with Lazy:
{ "navicore/patch-seq.nvim", ft = "seq", opts = {} }Features:
- Real-time diagnostics (parse errors, type errors, undefined words)
- Autocompletion for builtins, local words, and included modules
- Context-aware completions (stack effects, include statements)
- Syntax highlighting
Environment Variables:
| Variable | Default | Description |
|---|---|---|
SEQ_STACK_SIZE |
1048576 (1MB) | Coroutine stack size in bytes. Increase if you hit stack overflow in deeply nested (non-tail) calls. |
Example:
SEQ_STACK_SIZE=2097152 ./my-program # 2MB stacksdocs/ARCHITECTURE.md- System architecture and design decisionsdocs/TCO_DESIGN.md- Tail call optimization implementationdocs/TYPE_SYSTEM_GUIDE.md- Type system and stack effectsdocs/language-guide.md- Language syntax and semanticsdocs/ROADMAP.md- Development phases and milestones
MIT License