v0.2.0-alpha is released

This new release comes 7 months after the last release and brings a command-line tool for compiling and executing Stabel programs, as well as module support. This release renames the project from Play to Stabel (Norwegian word for stack). The previous name conflicted with Scala's Play Framework, as well as a few other projects.


Minor syntactic changes

Syntax has seen some minor adjustments since last release. I'll just list them here, but you can read the language proposal for more details.

First, deftype: has been renamed to defstruct: as it more precisely describes what you're defining.

The default constructor for a struct which has no members, is now the name of the type, instead of >TypeName.

Finally, for multifunctions you now define a branch using the default keyword (:) instead of when:. The catch-all branch is now else: instead of the default keyword.

To sum it up, the following code written with the previous release:

defunion: Something a
: a
: Empty

deftype: Empty

defmulti: pair-of
when: Empty
  >Empty >Pair
: dup >Pair

is now

defunion: Something a
: a
: Empty

defstruct: Empty

defmulti: pair-of
: Empty
  Empty >Pair
else: dup >Pair

CLI Tool

Stabel now has a CLI tool to let you compile and execute programs from the command line. As we're currently relying on node, you can download the tool from npm: npm install -g stabel-lang.

To setup a new project you can run the following command in a new folder: stabel init author/projectname.

This command will create a stabel.json file and a src folder with a single module. The stabel.json lists the metadata of the project, and where to find other modules and packages.

The CLI tool will not download third-party dependencies from a central repository, but such a tool could be written with what’s included now.

To execute a specific function, you can run: stabel run /author/projectname/module/fn-name. Currently, only functions with a type signature of  -- Int will work.

Module support

Any file that ends with .stbl is a Stabel module. The name of the module is the filename, as well as the relative path to the filename from the project source directory. So the function fn that is defined in the file <project_dir>/src/some/module.stbl can be referenced using the following qualified name: some/module/fn if the module is within the current project. If the module is defined in a third-party library, then it can be referenced using /some/module/fn (notice the leading slash).

By default, all definitions are exposed from a module, and to reference something in an external module, you'll use its qualified name. However, you're allowed to tweak these defaults by including a module definition at the top of the module. Something like:

exposing: fn1

def: fn1
: 1

def: fn2
: 2

In the above example, only fn1 is reachable from external modules. Also note that you don't need to provide a module name, as this is always defined by the filename and relative path.

You can also use alias: and import: keywords to avoid referencing external things with qualified names. What is interesting is that they can also be used at the function level and not just the module level, so something like this is possible:

alias: list /some/smart/list

def: example-list
type: -- list/List
import: /some/smart/list , # imports the function ',' from /some/smart/list 
: list/empty
  1 ,
  2 ,
  3 ,

You can read more about the design in this language proposal.

Standard library

Stabel now has a standard library. It will always be included in every project, and there are some default imports defined to make it easier to work with. You can read the source code to get an idea of what is included in this first iteration.

What's next

After the release of alpha-1, I spent the first month looking over the code and re-factoring the bits that were... rough. This gave me a good starting point for developing the next release, and I think it would be wise to do the same now. However, this time I'll release the cleanup work as v0.2.1-alpha, so that any bug-fixes will become available as soon as they're done.

I'm hoping that v0.3.0-alpha will be released around December, and the goal of the release is to include enhanced number literals (negative ints, hex-literals), arrays and strings. Some other features might make it in, but those are the major ones.

All features will first be proposed as a language proposal, which will be open for feedback before implementation starts. These proposals will be discussed in our Zulip chat so be sure to join us there if you want to be involved in that.