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

@exercism/codemirror-lang-reasonml

v1.0.2

Published

ReasonML language support for CodeMirror

Readme

ReasonML language support for CodeMirror

NPM Version

This package gives the CodeMirror 6 editor a Lezer grammar for ReasonML 3, with highlighting, indentation, folding and autocompletion. Exercism uses it in the in-browser editor for the ReasonML track.

⚠️ To keep the package working on the Exercism website, don't change the versions of these packages:

"@codemirror/language": "^6.10.1",
"@lezer/highlight": "^1.2.0",
"@lezer/lr": "^1.4.0"

Install

  • NPM: npm install @exercism/codemirror-lang-reasonml
  • Yarn: yarn add @exercism/codemirror-lang-reasonml
  • Bun: bun add @exercism/codemirror-lang-reasonml

Usage

import { EditorView, basicSetup } from "codemirror";
import { reasonml } from "@exercism/codemirror-lang-reasonml";

new EditorView({
  extensions: [basicSetup, reasonml()],
  parent: document.body,
});

What it does

  • It reads .re and .rei files: let bindings, types, modules, functors, module types, externals, attributes such as [@bs.val] and extensions such as [%re "/a/"].
  • It highlights keywords, strings, numbers, comments, definitions, function calls, types, constructors, record fields, labels and operators.
  • It indents inside braces, brackets and parentheses, and folds blocks, modules, records, lists, arrays and switch expressions.
  • Its autocompletion offers:
    • keywords, and snippets for let, a function, let rec, switch, if and else, record and variant types, module, module type, fun, an arrow function, for, while, try and exception.
    • the built-in values, types and constructors, such as string_of_int, option and Some.
    • a module's members after its name and a dot, such as List.map, Js.String.split or Belt.Option.getWithDefault. This covers the OCaml 4.06 standard library shipped with BuckleScript, and every Js and Belt module. Each member shows its type, such as (list('a), int) => 'a for List.nth. Option, Result, Int and Float complete as Belt's modules, which solutions use after open Belt.
    • the members of a module declared in the file.
    • the names declared in the file that are in scope at the cursor: values, functions, types, constructors, record fields, exceptions and modules declared above it, and the parameters and pattern variables of the functions, switch cases and loops around it.

How the grammar reads semicolons

Reason separates items with semicolons, but people often leave them out between top-level items. When the next token can't continue the current item, the fallback tokenizer in src/tokens.ts ends the item there. So let a = 1 on one line and let b = 2 on the next parse as two items, while f(x) followed by (y) on the next line still reads as one call.

The cases of a fun have no braces around them, so each case body is a single expression. A switch case body can hold several items separated by semicolons, but a type declaration inside a case body needs braces.

Updating the module lists

src/modules.ts is generated from the interface files in bs-platform 9, which is the compiler used by the ReasonML track. The script reads the OCaml .mli and .ml files and writes each type in Reason syntax. To regenerate it:

npm pack bs-platform@9
tar xzf bs-platform-9.0.2.tgz
node scripts/generate-modules.mjs package

The script prints how many members each module has.

Prerequisites

Setup

Run bun install to install all dependencies.

Developing

To help with development, run bun run dev. This starts a Vite dev server (usually at http://localhost:5173/) that renders index.html with some sample ReasonML code.

The grammar is in src/syntax.grammar, the external tokenizers are in src/tokens.ts, and the completion is in src/complete.ts and src/modules.ts.

Building

Run bun run prepare to build the package into dist/. It runs Rollup under Bun's runtime, because one of the Rollup plugins doesn't load in recent versions of Node.

Testing

Run bun run test. It builds the package and then runs the tests in test/.

  • test/cases/*.txt hold the grammar tests, in Lezer's test format.
  • test/completion.test.ts checks what the completion offers at a given position.

The tests use the built package, because the grammar needs the external tokenizers in src/tokens.ts.

Publishing

To publish a new version, set version in package.json and commit it. Then push a tag made of v followed by that version, for example v1.0.0. The tag starts the Publish workflow, which builds and tests the package and publishes it to npm. If the tag differs from version, the workflow stops before it publishes.