Quick Start
Create a Mix project, write a Gale module, and run it on the BEAM.
1. Install Gale
Section titled “1. Install Gale”curl -fsSL https://gale-lang.org/install.sh | bashThe 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.
2. Create a project
Section titled “2. Create a project”gale new hellocd hellomix deps.getThe 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.
3. Write a module
Section titled “3. Write a module”Replace lib/hello.🌀 with:
mod hello
pub fn advance(value: Integer) -> Integerrequires { 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.
4. Format, compile, and test
Section titled “4. Format, compile, and test”Replace test/hello_test.🌀 with:
mod hello_test
alias gale_std.test
pub fn advances_by_one() -> :ok { test.assert(hello.advance(41) == 42)}mix formatmix compilemix run -e 'IO.puts(Hello.advance(41))'mix testmix 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.
5. Optional: prove the contract
Section titled “5. Optional: prove the contract”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"] ]endmix gale.verifyCompilation 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.
Keep going
Section titled “Keep going”- Take the tour for language examples.
- Read the language guide for syntax and type rules.