Skip to content

Quick Start

Create a Mix project, write a Gale module, and run it on the BEAM.

Terminal window
curl -fsSL https://gale-lang.org/install.sh | bash

The installer checks for compatible Elixir/OTP, offers to install missing tools, and can configure your PATH. Choose proving tools if you want to verify contracts. Open a new terminal afterward, or run the activation command it prints.

Terminal window
gale new hello
cd hello
mix deps.get

The generated project includes a test, formatter configuration, and local copies of mix_gale and the standard library in vendor/. Gale’s repository is private for now, so the compiler bundles these libraries. Commit vendor/ with your code.

Replace lib/hello.🌀 with:

mod hello
pub fn advance(value: Integer) -> Integer
requires { value >= 0 }
ensures { result == value + 1 }
{
value + 1
}

mod hello becomes the Elixir module Hello. The contract requires a nonnegative input and says that the result is one greater than the input.

Replace test/hello_test.🌀 with:

mod hello_test
alias gale_std.test
pub fn advances_by_one() -> :ok {
test.assert(hello.advance(41) == 42)
}
Terminal window
mix format
mix compile
mix run -e 'IO.puts(Hello.advance(41))'
mix test

mix format handles Elixir and Gale files using the generated configuration. See formatter configuration for more options.

The program prints 42 and the test passes. lib/hello.g.ex contains the generated Elixir; keep editing the Gale source rather than that sidecar. The generated project enables runtime type and contract checks during tests.

Choose proving tools when running the installer. If you skipped them, rerun the same command to add them.

In mix.exs, add hello/advance to the proof selection:

defp gale do
[
runtime_typechecks: Mix.env() == :test,
proofs: ["hello/advance"]
]
end
Terminal window
mix gale.verify

Compilation checks types and contract formulas. Verification proves that advance satisfies its contract for every admitted input. Runtime tests check the cases they execute. See proof toolchain requirements.