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

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.

CopilotAI 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
FileDescription
test/Main.pursAdds unit tests for ST.run and STRef new/read/write/modify, plus a success log message.
src/Control/Monad/ST/Uncurried.luaWraps mkSTFn10 across lines to satisfy luacheck line-length constraints.
src/Control/Monad/ST/Uncurried.jsRemoves JS backend FFI implementation for ST uncurried helpers.
src/Control/Monad/ST/Internal.jsRemoves JS backend FFI implementation for core ST operations and STRef primitives.
src/Control/Monad/ST/.editorconfigRemoves per-subdir EditorConfig (tooling is centralized elsewhere).
spago.dhallAdds effect dependency and updates pslua backend entry/output settings.
spago-test.dhallAdds a test Spago config to compile Test.Main into dist/test.lua and include test deps.
scripts/testAdds a CI-friendly test runner that builds via spago-test.dhall and runs Lua 5.1.
scripts/buildHardens build script (set -euo pipefail) and uses plain spago build.
README.mdUpdates project identity and positioning as the Lua fork, plus current CI/docs links.
packages.dhallPoints the Lua package-set URL at the purescript-lua org location.
package.jsonRemoves legacy npm/pulp/eslint tooling configuration.
flake.nixReplaces easy-purescript tooling with purescript-overlay, pins toolchain, and adds nixConfig caches.
flake.lockUpdates lockfile to match the new flake inputs/toolchain.
CLAUDE.mdAdds a pointer to AGENTS.md for agent instructions.
AGENTS.mdDocuments the Lua 5.1 target, FFI conventions, and canonical build/test/lint commands.
.gitignoreCleans up ignores after removing node/bower-era artifacts.
.github/workflows/ci.ymlReplaces Node-based CI with Nix-based build/test/luacheck steps.
.eslintrc.jsonRemoves legacy ESLint configuration.

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

Comment threadtest/Main.purs
@Unisay
Unisayforce-pushed the chore/canon-and-tests branch from 46a98de to d970e93CompareJune 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
Unisayforce-pushed the chore/canon-and-tests branch from d970e93 to 1e40a04CompareJune 14, 2026 19:20
@Unisay
Unisay merged commit 850429c into masterJun 14, 2026
1 check passed
@Unisay
Unisay deleted the chore/canon-and-tests branch June 14, 2026 19:22
Sign up for freeto 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

@Unisay