Projects with stable
Create a project, run it, test it, format it and build it with one tool.
A single file is enough to try things out. For anything larger, use stable:
stable new hello
cd hello
stable run
stable new creates this layout:
hello/
build.rg the project: name, entry point, folders, dependencies
src/main/ridgun/hello/main.rg the program
src/test/ridgun/ the tests
build.rg is written in Ridgun too. Each setting is a function:
fn :: project name => String
project name = "hello"
fn :: dependencies => [String]
dependencies = []
The daily commands
| Command | What it does |
|---|---|
stable check | Checks the types of every module. |
stable test | Builds and runs every test in src/test/ridgun/. |
stable format | Aligns every .rg file into the canonical columns. |
stable built | Builds the executables into target/. |
stable run | Builds the program if needed, then runs it. |
stable deps | Fetches the dependencies listed in build.rg. |
A test
Tests import test and use assert equals and assert true:
import test
fn :: double Int => Int
double x = x * 2
fn :: main => ()
main =
assert equals (double 21) 42
assert true ((double 5) > 0)
Libraries
stable new --lib geometry creates a library. stable built lib turns it into a .rglib bundle and a native .so, which other projects import with import geometry.
Next, set up your editor.