Skip to content

Latest commit

 

History

5,008 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coal

Haskell CI

This repository is the home of the Coal programming language and compiler.

  1. About
  2. Documentation
  3. Installation and setup
  4. How to contribute
  5. License

About

Coal is a declarative, statically typed, purely functional programming language with simple and intuitive syntax. It provides algebraic data types and pattern matching, extensible records, structural recursion, codata, and traits (type classes), among other features. Coal’s type system, like Haskell’s and ML’s, supports type inference and parametric polymorphism, drawing on the System-F lambda calculus. The Coal compiler is implemented in Haskell and targets LLVM for code generation. As a total language, Coal takes a different approach to recursion, following the motto that "recursion is the goto of functional programming." To guarantee that programs are provably terminating, recursion is only available in a restricted form, known as structural recursion. The language finds inspiration in ideas from the field of Mathematics of Program Construction, where streams and other infinite data types are described as coalgebras — hence the name Coal.

Documentation

The language documentation is available at: coal-lang.org

Installation and setup

🐳 Docker

For instructions on how to use Coal in a Docker-based workflow, please see this page.

The compiler currently works on Linux and Mac OS. Windows support is not yet available.

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 && chmod +x project && ./project 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

Package management

A project declares its dependencies in a coal.json manifest. Start a new project with coal init, then add packages:

coal add https://codeberg.org/laserpants/coal-containers.git

Each dependency is pinned by a SemVer constraint, e.g. "0.5.1" (exact), ">=0.5.0", or "*".

See the CLI reference section of the documentation for more details.

How to contribute

This is an open and evolving project — contributions are welcome. Please see CONTRIBUTING.md for details.

Contributing coffee

Buy me a coffee

Documentation

The documentation is built with Zensical. The source code is hosted at: github.com/laserpants/coal-docs.

License

This project is licensed under the terms of the MIT license. See the LICENSE file in this repository for details.

Releases

Packages

Contributors

Languages