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:

  1. // ... is a comment line; all comments in Stella start with //; there are no multiline comments in Stella;
  2. 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;
  3. fn increment_twice(n : Nat) -> Nat { ... } declares a function increment_twice with a single argument n of type Nat and return type Nat; in Stella Core, all functions are single-argument functions;
  4. 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;
  5. succ(n) is an expression meaning "n + 1" (the successor of n);
  6. fn main(n : Nat) -> Nat { ... } declares a function main with a single argument n of type Nat and return type Nat; in a Stella program there must always be a main function declared at the top-level; main can take an argument of any type and return a value of any type;
  7. double(n) is an expression meaning "call double with argument n".