Skip to content
b4erPublic

About

A strict functional programming language in the ML family, with a compiler verified in Isabelle/HOL.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CaraML

A strict functional language in the ML family,
with a compiler verified in Isabelle/HOL.

CI/CD Release License

Website | Get started | Documentation | Releases


Why CaraML?

  • Formally verified: Machine-checked in Isabelle/HOL: well-typed programs never crash, and compilation preserves I/O behaviour down to the target code.
  • Total by default: Function types carry their (named) effects - no unstated side-effects. Divergence is an effect too, so a pure type means a total function.
  • Multi-shot handlers: A handler clause binds the resumption as an ordinary value. Call it once, many times, or never.
  • Modular implicits: Interfaces are signatures, instances are modules, nothing is canonical. Implicit arguments are elaborated from the instances in scope.
  • Statically interpreted modules: ML signatures, functors and sealing, compiled away by static interpretation. Expressive abstraction without runtime indirection.
  • Recursion schemes: Every type gets an Inductive instance from the compiler: a generic fold, with termination for free.
  • Layout syntax: UTF-8 source, user-defined operators, blocks by braces or by indentation. No preprocessor, no fixity tables.
  • Separate compilation: One file compiles to one module. Modules link after compilation, nothing is recompiled twice.

Quick start

Install your editor plugin, open a .caraml file and follow the dialog to install the compiler (either download from release, or build from sources).

VSCode / VSCodium

Install the extension from either

Spacemacs

In ~/.spacemacs, fetch the mode from git in dotspacemacs-additional-packages:

(caraml-mode :location (recipe :fetcher github :repo "b4er/caraml"
                               :files ("editors/emacs/local/caraml-mode/*.el")))

and start the language server in dotspacemacs/user-config:

(add-hook 'caraml-mode-hook #'caraml-eglot-ensure)

Emacs

Requires Emacs 29.1 or later (for Eglot). With Emacs 30, in your init.el:

(use-package caraml-mode
  :vc (:url "https://github.com/b4er/caraml"
       :lisp-dir "editors/emacs/local/caraml-mode")
  :hook (caraml-mode . caraml-eglot-ensure))

With Emacs 29, install once with M-x eval-expression:

(package-vc-install
 '(caraml-mode :url "https://github.com/b4er/caraml"
               :lisp-dir "editors/emacs/local/caraml-mode"))

and add (add-hook 'caraml-mode-hook #'caraml-eglot-ensure) to your init.el.

Overview

git clone --recursive https://github.com/b4er/caraml.git && cd caraml

This repository contains the Isabelle formalization split across the following roots:

prelude/ Shared Isabelle library (predictable, named cases)
spec/ Abstract compiler specification (program refinement and separate compilation)
syntax/ The abstract syntax for (module) expressions
parser/ Surface grammar and generated parser
core/ Core calculus
typing/ Type checking and inference
haskell/ Code exports
web/ Static website

You'll need Isabelle2025-2, the AFP (release 2026-07-21) to generate the verified code (writes to haskell/verified):

isabelle build -bed . CaraML_Export

The verified Haskell code is wrapped by the project in haskell/caraml.cabal and can be installed with Cabal:

cabal install --project-dir=haskell/ exe:caraml

The executable provides a language server which can be used by the editor plugins implemented in editors/.

License

CaraML is distributed under the BSD 3-Clause License.

About

A strict functional programming language in the ML family, with a compiler verified in Isabelle/HOL.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages