Note
This language is still under active development! Some features may not be set in stone yet and new features are still being added. This project will enter the alpha phase once all milestones are met.
An experimental compiled programming language focused on making the syntax as compact as possible without sacrificing readability.
\ this is a comment!
\ this imports `cout` from the standard library...
+std:cout
MY_CONST := "I'm a const variable"
myVar := "I'm a static variable"
myMutable ;= "I'm a mutable static variable"
\ adding an explicit type works too!
mySpecified: String = "I'm also a static variable"
\\ this is a multi-line doc-comment to be utilized by IDEs.
\\ no parameters, returns a string.
helloWorld :-> String
"Hello world!"
\\ 2 parameters, returns a string.
greet theirName myName: String String -> String
"Hello {theirName}! I'm {myName}."
\\ has a parameter, returns nothing.
\\ prints greeting to console based on input.
greetFriend creature: String
output ;= "Unknown friend: {creature}"
output = greet(creature "a crustacean too") <- creature == "Ferris" ; output
output = greet(creature "in a repo") <- creature == "Octocat" ; output
cout <| output
Tip
It may also be helpful to read <- as if, since it's used in ternary operations and also in matching pattern guards. A shorter ternary operation would look like the following:
response := "ready" <- is_ready ; "not yet"
Here are some more advanced examples:
factorial n: Z64 -> Z64
factorial(n-1) <- n > 1 ; 1
\\ tail-recursive version.
factorialTail n total: Z64 Z64 -> Z64
factorialTail(n-1 total*n) <- n > 1 ; total
\\ a simple struct.
Item =
name: String
amount; Z64
\\ now with generic type `t`!
Person =
name: String
age; Z64
items; t[2]
addItem: t
.items << item
getItems :-> *t[2]
*.items
\\ a simple trait.
Animal:
growUp years: Z64 -> Z64
\\ implement the Animal trait for Person struct...
Person => Animal
growUp years: Z64 -> Z64
.age += years
.age
Important
To actually run some code in Soulite, you would want a main function:
main args: [String]
output ;= "invalid argument(s) `{args.join(" ")}`"
output = "Usage: <exe_name> [-h] <command> <..args>" <- args.is_empty() ; output
output = "{factorialTail(args[1].parse().unwrap() 1)}" <- args.len() == 2 && args[0] == "fac" ; output
john ;= Person("John" 21 ["car keys" "credit card"])
john.growUp(3)
output = "{john.age}" <- args[0] == "people" ; output
cout <| output
Check out the wiki for an in-depth exploration!
$\color{green}\text{Variables}$
$\color{green}\text{Mutable}$ $\color{green}\text{Immutable}$ $\color{green}\text{Static}$ $\color{green}\text{Const}$
$\color{green}\text{Comments}$
$\color{green}\text{Single line}$ $\color{green}\text{Multi line}$
$\color{green}\text{Functions}$
$\color{green}\text{Parameter matching}$
$\color{green}\text{Pattern matching}$
$\color{green}\text{Literals}$ $\color{green}\text{Variables}$ $\color{green}\text{Wildcards}$ $\color{green}\text{Guards}$ $\color{green}\text{Generic types}$
$\color{green}\text{Structs}$
$\color{green}\text{Fields}$ $\color{green}\text{Generic types}$
$\color{green}\text{Methods}$
$\color{green}\text{Generic types}$ $\color{green}\text{Self field reference}$
$\color{green}\text{Traits}$
$\color{green}\text{Method declaration}$ $\color{green}\text{Generic types}$
$\color{green}\text{Struct implements}$
$\color{green}\text{Generic types}$ $\color{green}\text{Self field reference}$
$\color{grey}\text{Expressions}$
$\color{green}\text{Ternary conditional}$ $\color{green}\text{Anonymous functions}$ $\color{green}\text{Option data type}$ $\color{green}\text{Result data type}$
$\text{Data structures}$
$\color{green}\text{Arrays}$ $\color{green}\text{Lists}$ $\text{Tuples}$ $\text{HashSets}$ $\text{HashMaps}$
$\text{Loops}$
$\text{For loop}$ $\text{While loop}$ $\text{Infinite loop}$
$\color{grey}\text{Toolchain}$
$\texttt{soulite}—\text{completion of the milestones above}$ $\texttt{soulforge}—\text{package manager and build tool}$ $\texttt{soulfmt}—\text{code formatter}$ $\texttt{soulstd}—\text{standard library}$ $\texttt{souldocs}—\text{local docs webpage generator}$ $\texttt{soulsight}—\text{language server}$ $\texttt{soulsrc}—\text{local source code of standard library}$