Progetti con stable
Crea un progetto, eseguilo, testalo, formattalo e compilalo con un solo strumento.
Un solo file basta per fare delle prove. Per qualcosa di più grande, usa stable:
stable new hello
cd hello
stable run
stable new crea questa struttura:
hello/
build.rg the project: name, entry point, folders, dependencies
src/main/ridgun/hello/main.rg the program
src/test/ridgun/ the tests
Anche build.rg è scritto in Ridgun. Ogni impostazione è una funzione:
fn :: project name => String
project name = "hello"
fn :: dependencies => [String]
dependencies = []
I comandi di tutti i giorni
| Comando | Cosa fa |
|---|---|
stable check | Controlla i tipi di tutti i moduli. |
stable test | Compila ed esegue tutti i test in src/test/ridgun/. |
stable format | Allinea tutti i file .rg nelle colonne canoniche. |
stable built | Compila gli eseguibili in target/. |
stable run | Compila il programma se serve, poi lo esegue. |
stable deps | Scarica le dipendenze elencate in build.rg. |
Un test
I test importano test e usano assert equals e 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)
Librerie
stable new --lib geometry crea una libreria. stable built lib la trasforma in un pacchetto .rglib e in un .so nativo, che gli altri progetti importano con import geometry.
Poi, configura il tuo editor.