Coalton
Coalton is a statically typed language that runs inside Common Lisp. ZParen edits, checks and runs Coalton code in the same live image as Lisp code.
To start a Coalton project:
- Choose New Project, then choose Coalton in the Language row.
- Choose Create. A Coalton project always uses ocicl, so set up ocicl first.
- Wait for the first open to finish. ocicl downloads Coalton, and ASDF compiles it. This takes some minutes, and later opens use the compiled files.
The new project keeps its code in src/main.ct, Coalton's own file type. Its
.asd names "coalton" and "coalton-asdf" in :defsystem-depends-on, and
lists main as a :ct-file. Quicklisp's Coalton is from 2024 and cannot read
.ct files, so the dialog does not offer Quicklisp for Coalton.
In the editor and the REPL:
- Run Coalton forms. ⌘Enter on a
(coalton-toplevel …)block compiles it. A definition typed alone, such asdefine,declareordefine-type, runs insidecoalton-toplevel. An expression typed alone, such asmatchorlet, runs insidecoalton. - See types. Hover and
Kshow the Coalton type of a name, such as∀ :A. NUM :A ⇒ :A → :A. On a type, such asOptional, they show its kind, documentation and constructors. On a class, such asNum, they show its superclasses, documentation and methods. The search in the Documentation panel finds Coalton types and classes too. - Read the manual. For Coalton's operators, such as
match, and its library, such asOptionalormap, the Documentation panel (⇧⌘D) shows the page of Coalton's manual. Docstring switches to the text above. A library name also has a button for its package's part of the reference, such ascoalton/list. Once Coalton is loaded, the Coalton manual… menu opens the manual's other pages, such as Whirlwind tour, Lisp interop, Debugging and the library reference. The manual is online, so it needs a network connection. - Ask for help.
(help Optional)in the REPL prints the same, and for a value it prints its type and documentation. For a name that Coalton does not know, it prints what Lisp knows.(help)says how to use it. Ahelpfunction of your own still runs as before. - Fix type errors. The check as you type, ⌘Enter, and a file compile mark
the expression Coalton blames. The note shows Coalton's message without its
copy of the source. Copy and Ask AI to fix give the full message.
When Coalton suggests an edit, such as
_xfor an unused variablex, the note has a button that makes it. A type error in a form typed in the REPL prints Coalton's message in the REPL, and the debugger stays closed. A Lisp call such as(scale 10)to a Coalton function whose type has a constraint, such asNum :a, prints how to call it withcoalton, and the debugger stays closed. - Color. Coalton's operators, such as
define,matchanddeclare, have their own color. ZParen reads.ctand.coalfiles as Lisp source.
Coalton also has the .coal file type. A .coal file starts with a
(package …) form, and its definitions follow without coalton-toplevel. An
.asd lists such a file as a :coalton-file. ZParen compiles a .coal file
with Coalton's own compiler:
- ⌘B compiles and loads the file.
- Saving a loaded
.coalfile compiles all of it again. - The check as you type marks the expression Coalton blames.
- The
(package …)form sets the package for ⌘Enter, hover and completion.
Save a startup image after the first load. Lisp then starts with Coalton loaded, and does not compile it again.
Some limits apply:
- When a file compile finds a type error, the forms after it in the file do not load.
- When a
.coalfile has a type error, no part of it loads.