Using Coalton to Implement a Quantum Compiler

By Elias Lawson-Fox, Aidan Nyquist, and Robert Smith Updated July 1, 2025 by Robert Smith. Table Of Contents Introduction: Coalton and the quilc compiler Towards a discrete set of operations for quantum computation An approach to discrete compilation by Ross and Selinger Coalton’s strength in implementing math Discrete compilation in quilc Inaccuracy gotchas and validating the compiler Conclusion and how to get involved Acknowledgements Introduction: Coalton and the quilc compiler Quilc is a state-of-the-art optimizing compiler for quantum computers written in Common Lisp. It is capable of taking arbitrary quantum programs written in Quil, and compiling and optimizing them into code that conforms to the majority of quantum computing architectures that exist today. ...

September 6, 2022

Numbers in a Nutshell, an Update

By Robert Smith We discuss numbers and math in Coalton, as they are so far. Coalton is under active development, so this blog post may go out of date in due time. Table Of Contents Introduction The concrete types Rudimentary classes Arithmetic Reals, rounding, and related classes Complex numbers Powers, roots, and logs Trigonometry $\pi$ and elementary functions Big floats Precision of big floats Introduction Coalton is statically typed, which presents some challenges in how we work with numbers, both syntactically and semantically. For instance, consider the following Common Lisp code: ...

August 27, 2022

One Reason Typeclasses Are Useful

By Robert Smith In this post, we explore one way that typeclasses are useful. We do so by first painting ourselves into a corner while building a toy Common Lisp program, and then seeing how Coalton’s typeclasses can ameliorate the issues. A Graphics Library Let’s write a graphics library. Or, a tad less ambitiously, let’s write some routines for performing transformations on 2D points, which might serve as the foundation of a graphics library. We’ll be interested in: ...

December 12, 2021

AoC 2021 Coalton Contest

By Robert Smith Update: The prizes have been matched 1:1 by a donor who wishes to remain anonymous! Introduction Last September we announced Coalton, a statically typed language that is “just” another Common Lisp DSL. To our great surprise, there was a lot of excitement and fanfare, which made the development team feel quite honored and proud. It even made the top of Hacker News! Unsurprisingly, as is the case with many open-source projects, that fanfare lead to little “conversion”; only a few people actually gave Coalton a shot and provided feedback. We are immensely thankful to those who did! The good news is that it lead to some good discussion, great PRs, and fantastic internship applications from a wonderful and diverse group of people. We won’t be able to accept everyone but I’m pleased that there’s interest in helping build out the next generation of quantum computational tools using “alien technology”. :) ...

November 29, 2021

Introducing Coalton: How to Have Our (Typed) Cake and (Safely) Eat It Too, in Common Lisp

By Robert Smith, Elias Lawson-Fox, Cole Scott Updated July 1, 2025 by Robert Smith. Introduction Coalton is a statically typed functional programming language built with Common Lisp. We can load it like a normal Lisp library. CL-USER> (asdf:load-system "coalton") CL-USER> (in-package #:coalton-user) COALTON-USER> This is Coalton computing Fibonacci numbers by exponentiating functions (not numbers!): (coalton-toplevel (declare function-power (Integer -> (:t -> :t) -> (:t -> :t))) (define (function-power n f) (if (<= n 0) id (compose f (function-power (1- n) f)))) (declare fib-step ((Tuple Integer Integer) -> (Tuple Integer Integer))) (define (fib-step (Tuple a b)) (Tuple b (+ a b))) (declare fib (Integer -> Integer)) (define (fib n) (fst ((function-power n fib-step) (Tuple 0 1))))) This is Coalton greeting you by making native use of Common Lisp functions: ...

September 10, 2021