npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rescript-ic10-compiler

v0.2.0

Published

ReScript to IC10 compiler for Stationeers

Readme

ric10

Write Stationeers IC10 scripts in ReScript and compile them to IC10 assembly.

Your source is real ReScript: the official ReScript compiler type-checks it (with the bindings in IC10.res), and ric10 turns the same file into compact IC10 that fits the chip's 16 registers and 128 lines.

type state = Idle | Heating | Venting(float)

let sensor = device("d0")
let heater = device("d1")
let vent = device("d2")

let state = ref(Idle)

while true {
  let t = l(sensor, "Temperature")
  let p = l(sensor, "Pressure")
  state :=
    switch state.contents {
    | _ if p > 5000. => Venting(p)
    | Venting(_) if p > 1000. => Venting(p)
    | _ if t < 290. => Heating
    | _ => Idle
    }
  s(heater, "On", state.contents == Heating)
  s(vent, "On", switch state.contents { | Venting(_) => true | _ => false })
  yield()
}

Install

npm install -D rescript-ic10-compiler

or start a new project with type-checked bindings:

npx ric10 init my-scripts

Usage

npx ric10 furnace.res              # writes furnace.ic10
npx ric10 furnace.res --stdout     # print instead
npx ric10 furnace.res -o chip.ic10
npx ric10 furnace.res --debug      # also print the IR
npx ric10 furnace.res --alias      # alias lines for named devices (labels the screws in game)

The CLI prints warnings (non-exhaustive switch, more than 128 lines, lines longer than 90 characters) and the number of lines and registers used.

From JavaScript, in this repository (after npm run res:build):

import * as Compiler from "./src/compiler/Compiler.res.mjs";
const d = Compiler.compileWithDiagnostics(source);
d.ok ? console.log(d.code) : console.error(d.errors.map(Compiler.formatDiagnostic));

Language

A subset of ReScript 12, all of it valid ReScript:

  • let, shadowing, blocks, if/switch/blocks as expressions, c ? a : b
  • numbers are IC10 doubles; int division truncates like ReScript; true/false are 1/0
  • all operators: + - * / % **, +. family, comparisons, && || !, &&& ||| ^^^ ~~~ << >> >>>
  • ref, :=, .contents, while, for i in a to b / downto
  • functions with parameters and results, labeled parameters, closures over top-level values, pipes ->, higher-order functions (inlined)
  • variants with payloads, switch with or-patterns, guards, literal and wildcard patterns
  • IC10 bindings: l, s, ls, ss, lb, lbn, sb, sbn, lbs, lbns, sbs, hash, isSet, yield, sleep, hcf, stack (push, pop, peek, get, put, getd, putd), select, lerp, approx, Float.isNaN, Float.clamp, Math.*
  • %raw("...") for anything else; registers it mentions are left alone

Not supported (yet): records, tuples, arrays, strings beyond logic-type names, recursion.

See docs/user-guide/language-reference.md and docs/user-guide/ic10-bindings.md.

How it works

Lexer → Pratt parser → IRGen → optimizer (passes run to a fixpoint) → whole-program liveness → register allocation with copy coalescing → IC10. Functions called once are inlined; others are called with jal, and liveness keeps callee registers away from values the caller still needs. When more than 16 values are alive at once, long-lived state (variant and ref cells) moves to the top of the stack (put/get) and the registers stay with short-lived temporaries. See docs/architecture/compiler-overview.md.

Testing

npm test             # unit, emulator and differential tests
npm run test:fuzz    # 2000 random programs checked against ReScript

Generated code is executed in an IC10 emulator (tests/support/ic10.mjs). Differential tests compile each program with the real ReScript compiler too and require identical device-write traces. See docs/testing/ic10-tests.md.

License

MIT