Smelter

Smelter
Somewhere between the mainframe and the molten core

tl;dr: a CLI for Coalton scripts

I've been working on Smelter: a way to use Coalton for writing shell scripts and small CLI programs. It's an experimental way to get type-safe scripting with Common Lisp.

Starting Point: Coalton

Coalton is a statically-typed functional language embedded in Common Lisp. It has Hindley-Milner type inference, algebraic data types, and compiles to efficient SBCL code. I think it's great: the kind of type system that catches bugs without getting in your way (while still letting you drop down into Lisp when you need to).

I'd previously built the Coalton Playground, a web-based environment where you could try Coalton without installing anything. People seemed to like having a low-friction way to experiment with it.

The Gap

But there wasn't an easy way to use Coalton for quick scripts and CLI tools. You needed:

  • A full Common Lisp setup
  • Knowledge of ASDF and Lisp project structure
  • Time to set everything up properly

I wanted something simpler: write a .coal file, run it. No project setup, no boilerplate.

What Smelter Does

Smelter is basically a thin wrapper that makes Coalton work like a scripting language:

#!/usr/bin/env smt run
(declare validate-port (Integer -> (Result String Integer)))
(define (validate-port p)
  (if (and (>= p 1024) (<= p 65535))
      (Ok p)
      (Err "Port must be between 1024-65535")))

(define main
  (match (validate-port 80)
    ((Ok p) (print "Port valid"))
    ((Err msg) (print msg))))

Run it: smt run script.coal

All the type safety of Coalton, but with a script-friendly workflow.

Current State: Experimental

Let me be clear: this is not production-ready yet.

Right now it's useful for:

  • Build scripts
  • Data pipeline transforms (CSV, JSON)
  • Config validators
  • Learning Coalton without project setup overhead

But the stdlib is still minimal. You can't do much with HTTP, no regex support, limited file operations. It's enough for my use cases (build scripts and data transforms), but you'll hit walls quickly if you try to do anything complex.

That said, the foundation is solid. Coalton brings with it:

  • A robust type system
  • Good performance (compiles via SBCL)
  • Algebraic data types and pattern matching
  • Active development and a thoughtful design!

Smelter's stdlib can grow alongside your needs. The hard part (the type system and compiler) is handled by Coalton. I'm just filling in the missing pieces to make it script-friendly.

Why This Approach

Starting from Coalton gave me:

  • A proven type system: Coalton's type inference is solid
  • Real performance: SBCL generates fast native code
  • Good error messages: Coalton's errors are already pretty good
  • Less work: I didn't have to build a type system from scratch

It's standing on the shoulders of giants, I haven't done much here: my contribution is just making it easier to use for scripts.

Performance Notes

Startup time is ~99ms (Python: ~150ms, though Python has way more stdlib). Binary size is ~20MB, self-contained.

Fast enough that I don't notice it when running build scripts hundreds of times.

Try It (With Caveats)

If this sounds interesting:

curl -sSL https://smelter.app/install.sh | bash
smt run <(echo '(print "Hello!")')

Examples: https://github.com/abacusnoir/smelter/tree/master/examples/showcase

Fair warning:

  • Documentation is minimal
  • Stdlib is limited (though growing)
  • You'll hit rough edges
  • It's a side project, not a company-backed thing

If you already know Coalton, this will feel familiar. If you're new to both, the Coalton docs are actually pretty good starting point.

Roadmap (Tentative)

Things that would move this toward production-readiness:

  • Expand stdlib: HTTP client, regex, better file I/O, process management
  • Better error messages: Make type errors more script-friendly
  • Package management: Import libraries, share code
  • More examples: Common script patterns

The type system doesn't need work - Coalton already has that figured out. It's mostly about building out the practical tooling.

Who This Is For

Honestly? Probably a pretty small audience:

  • You write lots of scripts/automation
  • You've been burned by runtime errors in bash/Python
  • You think "ML-style types for shell scripts" sounds fun, not scary
  • You're okay with rough edges in exchange for trying something different

If you're happy with bash or Python, stick with those. This is for people who have the specific problem of "I want type safety but bash is too loose and compiled languages are too heavy."

The Meta Point

Beyond Smelter itself, I think there's something interesting about making powerful type systems more accessible. Coalton is great, but the barrier to entry is high. If we can lower that barrier - whether through web playgrounds or CLI tools - more people get to experience what good type systems feel like.

That was the goal with the Coalton Playground, and it's the goal here. Make the on-ramp easier.

Feedback Welcome

If there are more stdlib additions, or UX improvements, or bugs, let me know: drop a DM on Twitter/X or open an issue on GitHub.


Smelter is open source (MIT).

Reminder again: All the real magic is Coalton: I just wrapped it in a scripting interface.

Thanks to the Coalton team for building something genuinely good to build on top of.