Introduction to Stella Core
The core language of Stella is essentially a simply-typed functional programming language, similar to Programming Computable Functions, except having a C-style syntax, familiar to many programmers.
Here is a sample program in Stella Core:
// sample program in Stella Core
language core;
fn increment_twice(n : Nat) -> Nat {
return succ(succ(n))
}
fn main(n : Nat) -> Nat {
return increment_twice(n)
}
Let us explain each part of this program:
// ...is a comment line; all comments in Stella start with//; there are no multiline comments in Stella;language core;specifies that we are using just Stella Core without any extensions; it is mandatory to specify the language in the first line of a Stella program;fn increment_twice(n : Nat) -> Nat { ... }declares a functionincrement_twicewith a single argumentnof typeNatand return typeNat; in Stella Core, all functions are single-argument functions;return ...;is a mandatory part of every function; in Stella Core each function can only return some expression, there are no assignments, operators, or other statements possible;succ(n)is an expression meaning "n + 1" (the successor of n);fn main(n : Nat) -> Nat { ... }declares a functionmainwith a single argumentnof typeNatand return typeNat; in a Stella program there must always be amainfunction declared at the top-level;maincan take an argument of any type and return a value of any type;double(n)is an expression meaning "calldoublewith argumentn".