Skip to content

feat: bring st to the canon and add ST unit tests#1

Merged
Unisay merged 1 commit into
masterfrom
chore/canon-and-tests
Jun 14, 2026
Merged

feat: bring st to the canon and add ST unit tests#1
Unisay merged 1 commit into
masterfrom
chore/canon-and-tests

Conversation

@Unisay

@Unisay Unisay commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Brings purescript-lua-st onto the package-set canon and gives it a working Lua test suite.

Scaffolding. Replaces the JavaScript-era tooling (npm/bower CI, easy-purescript flake, .eslintrc, package.json, .js FFI) with the canon: an overlay flake pinning purs 0.15.16 / spago 0.21.0 / Lua 5.1 and pslua at the current main, hardened CI, scripts/build, AGENTS.md + CLAUDE.md, a clean .gitignore, and the purescript-lua org package-set URL.

Tests. spago-test.dhall compiles test/Main.purs to dist/test.lua through pslua; scripts/test runs it under Lua 5.1. The suite asserts ST.run with STRef new/read/write/modify (sum of squares, write-then-read, modify-returns-new).

Fixes found along the way. Control.Monad.ST.Global imports Effect, so effect is now a declared dependency; and one mkSTFn10 line in the Uncurried FFI was over 120 cols, so it is wrapped to keep luacheck --std lua51 clean.

Verified locally: build, scripts/test (all ST tests passed), and luacheck all green.

@Unisay Unisay requested a review from Copilot June 14, 2026 19:04
@Unisay Unisay self-assigned this Jun 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes purescript-lua-st to match the purescript-lua package-set “canon” (Nix flake + Spago + pslua backend) and introduces a runnable Lua 5.1 unit test suite for core ST/STRef behavior.

Changes:

  • Replace legacy JS-era tooling (npm/bower/eslint/pulp + JS FFI remnants) with a Nix flake dev shell and hardened GitHub Actions CI.
  • Add a Spago test config and shell test runner that builds test/Main.purs to dist/test.lua and runs it under Lua 5.1.
  • Update package metadata/docs (Spago deps, package-set URL, README, contributor/agent docs).

Reviewed changes

Copilot reviewed 17 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/Main.purs Adds unit tests for ST.run and STRef new/read/write/modify, plus a success log message.
src/Control/Monad/ST/Uncurried.lua Wraps mkSTFn10 across lines to satisfy luacheck line-length constraints.
src/Control/Monad/ST/Uncurried.js Removes JS backend FFI implementation for ST uncurried helpers.
src/Control/Monad/ST/Internal.js Removes JS backend FFI implementation for core ST operations and STRef primitives.
src/Control/Monad/ST/.editorconfig Removes per-subdir EditorConfig (tooling is centralized elsewhere).
spago.dhall Adds effect dependency and updates pslua backend entry/output settings.
spago-test.dhall Adds a test Spago config to compile Test.Main into dist/test.lua and include test deps.
scripts/test Adds a CI-friendly test runner that builds via spago-test.dhall and runs Lua 5.1.
scripts/build Hardens build script (set -euo pipefail) and uses plain spago build.
README.md Updates project identity and positioning as the Lua fork, plus current CI/docs links.
packages.dhall Points the Lua package-set URL at the purescript-lua org location.
package.json Removes legacy npm/pulp/eslint tooling configuration.
flake.nix Replaces easy-purescript tooling with purescript-overlay, pins toolchain, and adds nixConfig caches.
flake.lock Updates lockfile to match the new flake inputs/toolchain.
CLAUDE.md Adds a pointer to AGENTS.md for agent instructions.
AGENTS.md Documents the Lua 5.1 target, FFI conventions, and canonical build/test/lint commands.
.gitignore Cleans up ignores after removing node/bower-era artifacts.
.github/workflows/ci.yml Replaces Node-based CI with Nix-based build/test/luacheck steps.
.eslintrc.json Removes legacy ESLint configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/Main.purs
@Unisay Unisay force-pushed the chore/canon-and-tests branch from 46a98de to d970e93 Compare June 14, 2026 19:18
Migrate purescript-lua-st off the JavaScript-era tooling onto the
package-set canon: an overlay flake (purs 0.15.16, spago 0.21.0, Lua 5.1,
pslua at the current main), hardened CI, scripts/build, AGENTS.md and
CLAUDE.md, a clean .gitignore, and the org package-set URL. Drop the
.eslintrc, package.json and the JavaScript FFI files.

Add a systematic test suite: spago-test.dhall compiles test/Main.purs to
dist/test.lua through pslua and scripts/test runs it under Lua 5.1. It
covers STRef new/read/write/modify/modify', ST.run recursion, ST.for
(hi-exclusive, lo-inclusive, empty range), ST.while and ST.foreach.

Fixes surfaced by the new tests and luacheck: ST.for looped over an
inclusive upper bound (for i = lo, hi) though the contract is
hi-exclusive, so it ran one extra iteration -- corrected to hi - 1.
Declare the effect dependency that Control.Monad.ST.Global needs, and
wrap an over-long line in the Uncurried FFI so luacheck passes.
@Unisay Unisay force-pushed the chore/canon-and-tests branch from d970e93 to 1e40a04 Compare June 14, 2026 19:20
@Unisay Unisay merged commit 850429c into master Jun 14, 2026
1 check passed
@Unisay Unisay deleted the chore/canon-and-tests branch June 14, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants