A language you can trust
with code you didn't write.

Python is easy to write, but any library you install can read your files, steal your keys, or phone home. Cresset keeps the easy feel and adds one rule: every function declares what it may touch, and the compiler enforces it.

One rule, enforced

A function lists the effects it needs. Using anything it didn't list, directly or through another function, is an error before a single line runs.

# examples/denied.crs
fn left_pad(text, width):
    secret = read("C:/Users/secrets.txt")
    return text

fn main() needs print:
    print(left_pad("hi", 5))
error: 'left_pad' uses 'read', which needs the 'read' permission, but doesn't declare it
  --> examples/denied.crs:5
   |  secret = read("C:/Users/secrets.txt")
help: add the permission to the signature:  fn left_pad(text, width) needs read:

A program may only print unless you grant more when you run it. Nothing sneaks through, even passing an effect around as a value counts.

Packages only get what you grant them

You decide, per import, exactly what a dependency may do.

use textutil from "lib/textutil.crs"            # pure: needs nothing
use files    from "lib/files.crs" allow read    # may read files, nothing else
use evil     from "lib/evil.crs"                # wants the network? refused
error: package 'evil' wants permissions you did not grant it: network
help: tidy() needs network. you granted nothing. If you trust it:  use evil from "lib/evil.crs" allow network

Everything else, kept simple

Record and replay

Time, randomness and files are effects, so any run can be recorded and replayed exactly. Bugs that happened once can be reproduced forever.

Types you don't have to write

Cresset infers types and checks them before running. Add annotations where you want a promise held. It only reports an error when it is certain.

Errors are values

ok(x) and err(msg), with ? to pass a failure up. No hidden exceptions.

Contracts

requires and ensures on any function, with messages that name the exact promise that broke.

Your own types, and no forgotten cases

record and enum, plus a match that refuses to run if you leave a case out.

A local redaction tool

Swap secrets and personal data for placeholders before you paste text anywhere, then restore the real values. It runs on your machine and sends nothing. Try Scrub.

Errors for humans

Every error shows the line, the code, and a concrete fix, with "did you mean" for typos.

Nothing to install

The whole interpreter is plain JavaScript. It runs on Node.js, and right here in your browser.

It feels like this

fn total_scores(path) needs read:
    text = read(path)?
    nums = text.lines().try_map(to_int)?
    return ok(nums.sum())

fn main() needs print, read:
    print("Total: {total_scores("scores.txt").unwrap()}")

Where it is today

Cresset is young: version 0.2, a working language with a large test suite, a formatter, editor support, a package registry you can run yourself, and an interactive tutorial. It is a real foundation, not a finished language. Here is the honest picture.

Works todayNot built yet
Effect checking, static and at run timeA shared public registry
A package registry you can run yourself, showing permissions before installPackages that depend on other packages
Lock file pinning packages by hashFetching packages by name
Per-run permission grants, real network access (fetch, post)HTTP headers and other methods
Local packages with per-package grants, sharing records and enumsMethods on records
Records, enums and exhaustive matchSeparate type names per package
Record and replayStructured concurrency
Gradual static types, optional annotationsCompile to a single native binary
Errors as values, contractsEditors other than VS Code
Local redaction tool (command line and browser)Function types and generics
Full documentation, browser playgroundA compiled, much faster implementation
Formatter, and a VS Code extension with errors as you typeA package registry