Skip to content

Getting started

Installation and setup

The compiler has been tested on Linux and Mac OS.

Prerequisites

Haskell/GHC

A recent version of GHC is needed. It is recommended to install Haskell, GHC and Stack using the GHCup tool.

LLVM

An LLVM toolchain that provides llvm-as and llc (the LLVM static compiler) is also required.

Linux
  • Debian/Ubuntu (or derivatives):
sudo apt update
sudo apt install llvm clang     
  • Fedora, RHEL, or CentOS:
sudo dnf install llvm clang
  • Arch Linux:
sudo pacman -S llvm
Mac OS

See Getting Started with the LLVM System, or install using Homebrew:

brew install llvm

Note: If you use Homebrew to install LLVM, you may need to add the binaries to your PATH manually.

Additional dependencies

Linux
  • Debian/Ubuntu (or derivatives):
sudo apt update
sudo apt install libgc-dev libgmp-dev build-essential
  • Fedora, RHEL, or CentOS:
sudo dnf install gc-devel gmp-devel gcc make
  • Arch Linux:
sudo pacman -S gc gmp base-devel
Mac OS
brew install bdw-gc gmp

Building the compiler

Clone the repository:

git clone ssh://git@codeberg.org/laserpants/coal.git
cd coal && stack install

Restart or refresh your shell, using e.g., exec $SHELL -l. To verify that the executable is installed, run:

coal --version

Hello, world!

module Main {

  import IO(println_string)

  fun main() =
    println_string("Hello, world!")

}

Save this program as "Main.coal". Compile the program with the command:

coal compile -I. Main.coal -o dist