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-purescript

v1.0.2

Published

PureScript language support for CodeMirror

Readme

PureScript language support for CodeMirror

NPM Version

This package gives the CodeMirror 6 editor a Lezer grammar for PureScript, with highlighting, folding, indentation and autocompletion. Exercism uses it in the in-browser editor for the PureScript 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-purescript
  • Yarn: yarn add @exercism/codemirror-lang-purescript
  • Bun: bun add @exercism/codemirror-lang-purescript

Usage

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

new EditorView({
  doc: "main = log \"Hello\"",
  extensions: [basicSetup, purescript()],
  parent: document.body,
});

What it supports

The grammar reads modules, imports and exports, functions with signatures and guards, where, let, do, ado, case (including several values at once), if, lambdas, operator sections and backtick operators. It also reads data types, newtypes, type synonyms, kind signatures, classes, instances and instance chains, derived instances, foreign imports and fixity declarations. For records, it reads literals, puns, patterns, updates, field access such as p.name and accessor sections such as _.name. In types, it reads rows, open records, forall, constraints and the Unicode spellings of ::, ->, <-, => and forall.

PureScript uses indentation to open and close blocks. The tokenizer in src/tokens.ts follows the indentation and tells the grammar where each block opens, where each item starts and where each block ends.

Completion offers:

  • the keywords
  • snippets for functions, guards, case, if, let, where, do, lambdas, folds, data types, newtypes, records, classes, instances, imports and the module header
  • the names exported by Prelude, and the common functions, types and constructors from modules such as Data.Array, Data.Maybe, Data.String, Data.Tuple, Data.Map and Effect.Console
  • the names declared in the file that are in scope at the cursor, such as functions, types, constructors, parameters, pattern variables, and bindings from let, where, do and ado
  • record field names from the file after a dot

It offers nothing inside strings and comments.

Credits

The grammar and the layout tokenizer are adapted from codemirror-lang-haskell by CodinCod, which is released under the MIT licence.

Prerequisites

Structure

.
├── src
│   ├── index.ts (the language support: highlighting, folding and indentation)
│   ├── complete.ts (the completion sources and snippets)
│   ├── syntax.grammar (the Lezer grammar)
│   ├── tokens.ts (the layout, comment, record and name tokenizers)
│   └── syntax.grammar*.d.ts (the grammar typings)
├── test
│   ├── cases (grammar test cases)
│   ├── grammar.test.ts (runs the grammar test cases)
│   ├── complete.test.ts (completion tests)
│   └── editor.test.ts (folding, indentation and highlighting tests)
├── index.html (dev server file)
├── rollup.config.js (bundling config)
├── tsconfig.json (TypeScript config)
└── vite.config.js (Vite dev server config)

Setup

Run bun install to install all dependencies.

Developing

Run bun run dev to start a Vite dev server, usually at http://localhost:5173/. It shows index.html, which loads some sample PureScript into an editor that uses this package. The page reloads when the grammar changes.

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, because the grammar tests use the built parser. Each file in test/cases holds grammar test cases. Keep each case small and about one feature.

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.