|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +A PureScript→Lua FFI fork in the [`purescript-lua`](https://github.com/Unisay/purescript-lua) package set. Generated code targets **Lua 5.1**. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +All commands run inside the nix dev shell: |
| 8 | + |
| 9 | +- Build: `nix develop -c ./scripts/build` |
| 10 | +- Test (only if the fork has `scripts/test`): `nix develop -c bash ./scripts/test` |
| 11 | +- Lint: `nix develop -c luacheck --quiet --std lua51 --no-unused-args src/` |
| 12 | + |
| 13 | +## Lua 5.1 target |
| 14 | + |
| 15 | +The output runs on Lua 5.1, which is stricter than 5.3: |
| 16 | + |
| 17 | +- No `table.unpack`, `bit32`, `utf8`, or the `//` operator. `math.pow` and `math.atan2` do exist. |
| 18 | +- Array-style tables are 1-indexed: the first element is `t[1]`, not `t[0]`. |
| 19 | +- `unit` is `{}`, never `nil`: a `nil` table element silently disappears, which would collapse `Array Unit` into an empty table. |
| 20 | +- Lua 5.1 mangles some Lua 5.3 string escapes, so keep FFI string escapes 5.1-safe. |
| 21 | + |
| 22 | +## FFI files (under `src/`) |
| 23 | + |
| 24 | +pslua's foreign-file parser needs every exported value wrapped in parentheses: |
| 25 | + |
| 26 | +```lua |
| 27 | +return { |
| 28 | + identity = (function(x) return x end), |
| 29 | + answer = (42), |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +A bare `function … end` or an unparenthesised expression fails to parse. |
| 34 | + |
| 35 | +## Toolchain |
| 36 | + |
| 37 | +`flake.nix` pins everything through [`purescript-overlay`](https://github.com/thomashoneyman/purescript-overlay): purs 0.15.16 (`purs-bin.purs-0_15_16`), spago 0.21.0 (`spago-bin.spago-0_21_0`), Lua 5.1 (`lua51Packages`). The `pslua` input tracks `github:Unisay/purescript-lua`; keep `flake.lock` reasonably current, since a long-stale pslua pin won't create the `--lua-output-file` directory and CI fails. |
| 38 | + |
| 39 | +## Releasing |
| 40 | + |
| 41 | +Tag-driven, with no GitHub Release or changelog entry. The full conventions live in the [package-set repo](https://github.com/Unisay/purescript-lua-package-sets/blob/master/CONTRIBUTING.md): push an annotated tag on `master`, bump this fork's `version` in the package set's `src/packages.dhall`, refresh `latest-compatible-sets.json`, and push a `psc-*` set tag. |
| 42 | + |
| 43 | +## Decisions |
| 44 | + |
| 45 | +Cross-cutting decisions are recorded as ADRs in the [package-set repo](https://github.com/Unisay/purescript-lua-package-sets/tree/master/docs/adr). Read them before a decision that affects the set, and add one after making such a decision. |
0 commit comments