Alice v0.6.0

Announcing the release of Alice v0.6.0!

This change introduces several new features needed to build a small collection of packages from the Opam repository which I’ve been manually porting to Alice’s package format in alice-ports.

New Features

Access built-in modules from the standard library

Alice packages may now refer to modules from the standard library which are excluded from the prelude, such as Unix and Str. A new builtins section in Alice.kdl can be used to list the built-in modules a package can access:

package {
  name foo
  version "0.1.0"

  builtins {
    unix
  }
}

Mixing C code with OCaml

Packages may include C source files in their src directory. All C files will be compiled and linked into the resulting executable when building a project. The ability to compile C code raises the question of how to pass custom linker arguments to the C compiler, and this is addressed with another new feature: config scripts.

Config Scripts

A package may include a config script in a file named config.ml file in the package’s root directory (next to Alice.kdl). The config.ml file is compiled and executed as the first step of building a package, and any lines in its standard output beginning with alice: are interpreted by Alice as directives that can influence the build. Currently the only supported directives are alice:print_endline which prints a message, and alice:add_c_linker_args which adds C linker arguments.

Config scripts can depend on other packages, and also access built-in modules from the standard library. This can be configured in Alice.kdl:

package {
  name bar
  version "0.1.0"

  config_script {
    dependencies {
      foo path="../foo"
    }

    builtins {
      str
    }
  }
}

Config scripts are expected to be run only once each time they are compiled because their output can be trivially cached in the build directory. For this reason it’s faster to compile config scripts with the bytecode compiler rather than the native compiler, and of course this means compiling all their dependencies with the bytecode compiler too.

Packages can be built with the bytecode compiler

This was a necessary feature for allowing config scripts to be built with the bytecode compiler, but it might also be something people find useful to integrate into their workflow, since the bytecode compiler backend is generally faster than the native backend (but of course the executables it produces are generally slower to run).

Commands that compile code (e.g. alice build, alice run) now take a --backend argument which can be passed native or bytecode. The default is native.

Install Alice v0.6.0

On Windows, Alice v0.6.0 can be installed with WinGet:

winget install OCaml.Alice --version 0.6.0

On macOS and Linux, the latest version of Alice can be installed with Homebrew:

brew install alicecaml/homebrew-tap/alice

Alternatively, on macOS and Linux, Alice v0.6.0 can be installed by running the install script:

curl -fsSL https://alicecaml.org/install.sh | sh -s -- 0.6.0

On NixOS, Alice v0.6.0 can be installed via the flake github:alicecaml/alice#alice_0_6_0.default, e.g.:

nix shell github:alicecaml/alice#alice_0_6_0.default

Read more about installing Alice here.

Release Notes

Added