A statically-typed functional programming language with structural typing, pattern matching, lightweight processes, typed message passing, and a pipeline syntax.
Try Quiver in the online REPL// Define a recursive list type (matching the list module's)
'list<'t> = Nil | Cons['t, ^]
// Define a function to compute the sum of a list using tail recursion
sum = #['list<'int>, (acc): 'int = 0] {
| =[Nil, acc: acc] => acc
| =[Cons[head, tail], acc: acc] => {
%num.add [head, acc] ~> ^ [tail, ~]
}
}
// Entrypoint of the program
#[] {
// Build a list (using the list module's dialect), and sum it
%list{ 1, 2, 3 } ~> sum [~] //= 6
}
Run the example above in the REPL (
quiv repl, or at quiver.run), or run the executable version in examples/sum.qv withquiv run examples/sum.qv.
- Pipeline syntax: Data flows left-to-right through
~>-separated transformations - Structural typing: Types are defined by their structure, not their names
- Pattern matching: Destructure and branch on values with expressive pattern syntax
- Union types: Model complex data with algebraic types
- Tail recursion: Efficient recursive algorithms via explicit tail-calls
- Concurrent processes: Erlang-inspired lightweight processes with typed message passing
See docs/guide.md for the language guide.
Clone the repository and build:
git clone https://github.com/joefreeman/quiver.git
cd quiver
cargo build --releaseThe compiled binary will be at target/release/quiv.
Run the REPL:
quiv replExecute a Quiver program:
quiv run program.qvquiv repl- Start an interactive REPL sessionquiv run [FILE]- Run a Quiver program (.qvsource or.qxbytecode)-e, --eval <CODE>- Execute code directly from the command line-q, --quiet- Print nothing but the program's own output--release- Skip failure-provenance stamps (runcompiles debug by default)
quiv compile [FILE]- Compile source to bytecode-o, --output <FILE>- Write output to file--debug- Include failure-provenance stamps in the bytecode--inline- Inline imported modules into the entry unit, shaken to what it reaches-e, --eval <CODE>- Compile code directly from the command line
quiv inspect <FILE>- Inspect compiled bytecode structurequiv format [PATH]...- Format files in place, walking any directory given (default: the current one)--check- Write nothing; list what would change and exit non-zero-e, --eval <CODE>- Format code directly from the command line
quiv test <FILE.md>...- Run the Quiver code embedded in a Markdown document and check its//=assertions. Each##chapter is one accumulating session; exits non-zero if any check failsquiv server- Run the persistent server: one shared environment that client sessions connect to over a unix socket.quiv runandquiv replspawn one automatically when none is listening, so this is only needed to run it in the foreground or to reach it from a browser--socket <PATH>- Listen on this socket path instead of the per-user default--listen [<ADDRESS>]- Additionally listen for browser clients on a loopback TCP address (default127.0.0.1:2192). Every request must carry the bearer token written beside the socket; non-loopback addresses are refused--allow-origin <ORIGIN>- Allow this browser origin on the TCP listener (repeatable)quiv server status/quiv server stop- Whether a server is listening, and stop it
Commands read from stdin when no file is specified (quiv format spells that -).
Within the REPL:
\?- Show help message\q- Exit the REPL\!- Reset the REPL\r- Reload project modules (keeps variables)\v- List all variables\p- List all processes\p X- Inspect process with IDX\w- List workers\w X- Inspect worker with IDX\x- Show the compile-time type of the last expression
MIT