lawspec 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -14
- package/bin/lawspec.mjs +2 -2
- package/build.json +4 -4
- package/core.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,28 +8,35 @@ WebAssembly with a Node CLI and an asynchronous, typed JavaScript API.
|
|
|
8
8
|
|
|
9
9
|
## Install and try it
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Install [LawSpec from npm](https://www.npmjs.com/package/lawspec):
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
npm
|
|
15
|
-
|
|
14
|
+
npm install --save-dev lawspec@0.2.1
|
|
15
|
+
npx lawspec --version
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
Node 22+ and the selected target's build tools are required. No Haskell toolchain
|
|
19
|
+
is needed to install or run LawSpec. The reference platforms are macOS and Linux.
|
|
20
|
+
Use `npx lawspec` to run the locally installed CLI.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
To try it in a **new, empty directory**, initialize the starter before installing
|
|
23
|
+
local dependencies so LawSpec can create its `package.json` and test script:
|
|
23
24
|
|
|
24
25
|
```sh
|
|
25
|
-
lawspec
|
|
26
|
-
|
|
27
|
-
lawspec
|
|
28
|
-
|
|
29
|
-
lawspec
|
|
30
|
-
lawspec
|
|
26
|
+
mkdir lawspec-example
|
|
27
|
+
cd lawspec-example
|
|
28
|
+
npm exec --package=lawspec@0.2.1 -- lawspec init --target javascript
|
|
29
|
+
npm install --save-dev lawspec@0.2.1
|
|
30
|
+
npx lawspec check
|
|
31
|
+
npx lawspec explain 'example.atoi_codec::itoa and then atoi yields a'
|
|
32
|
+
npx lawspec doctor
|
|
33
|
+
npx lawspec generate
|
|
31
34
|
```
|
|
32
35
|
|
|
36
|
+
In an existing project, install LawSpec first, then run
|
|
37
|
+
`npx lawspec init --target javascript`. Existing build files are preserved;
|
|
38
|
+
apply the printed dependency and test-runner setup instructions before generation.
|
|
39
|
+
|
|
33
40
|
Implement `src/example/atoi_codec.mjs`, then run `npm test`:
|
|
34
41
|
|
|
35
42
|
```javascript
|
|
@@ -192,7 +199,7 @@ This expands to `for all (x :: Int32) . render (x) = referenceRender (x)`.
|
|
|
192
199
|
The example inherits the input name `x` from the prelude. Both functions are
|
|
193
200
|
user-owned adapter functions; either may delegate to your existing code.
|
|
194
201
|
|
|
195
|
-
[The complete example](examples/specs/equivalent.lawspec) compares decimal
|
|
202
|
+
[The complete example](https://github.com/brain-fuel/lawspec/blob/v0.2.1/examples/specs/equivalent.lawspec) compares decimal
|
|
196
203
|
renderers and two implementations that clamp negative integers to zero. For
|
|
197
204
|
JavaScript, their adapters can be:
|
|
198
205
|
|
|
@@ -247,6 +254,10 @@ by the JS shim.
|
|
|
247
254
|
|
|
248
255
|
## Build and verify
|
|
249
256
|
|
|
257
|
+
For contributors working from a repository checkout, build a local archive with
|
|
258
|
+
`npm pack ./npm` and install it with `npm install --save-dev ./lawspec-0.2.1.tgz`.
|
|
259
|
+
The package payload lives in `npm/`.
|
|
260
|
+
|
|
250
261
|
```sh
|
|
251
262
|
stack test
|
|
252
263
|
# With wasm32-wasi-cabal and wasm32-wasi-ghc installed:
|
package/bin/lawspec.mjs
CHANGED
|
@@ -153,13 +153,13 @@ async function init() {
|
|
|
153
153
|
async function main() {
|
|
154
154
|
if (!verb || ["help", "--help", "-h"].includes(verb)) {
|
|
155
155
|
output(
|
|
156
|
-
"LawSpec 0.2.
|
|
156
|
+
"LawSpec 0.2.1\nUsage: lawspec init --target <language> [--project <directory>]\n lawspec check | doctor | explain <unit>::<law> | generate\nOptions: --config <path>, --target <language>, --json\nGeneration: --dry-run, --check\nTargets: " +
|
|
157
157
|
targets.join(", "),
|
|
158
158
|
);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
if (verb === "--version") {
|
|
162
|
-
output("0.2.
|
|
162
|
+
output("0.2.1");
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
165
|
if (positional.length > (verb === "explain" ? 1 : 0))
|
package/build.json
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"wasm/lawspec-wasm.cabal"
|
|
18
18
|
],
|
|
19
19
|
"digests": {
|
|
20
|
-
"package.yaml": "
|
|
20
|
+
"package.yaml": "2cc5254bf0c1de94adbb98ee193dd45f5d8e5efced9ce255508112ccbca96793",
|
|
21
21
|
"src/LawSpec/Api.hs": "00b1e4bc81231ebd387f10652463904084ebf9c3c4486fd2c2217a6d4dbfc157",
|
|
22
22
|
"src/LawSpec/Compile.hs": "c1727ba7d6ece9725567f9561d341d8660b3293ff845c2de1d936ebdd2cd5fc6",
|
|
23
|
-
"src/LawSpec/Emit.hs": "
|
|
23
|
+
"src/LawSpec/Emit.hs": "4e223dfc975c5b66021e7a012a063edd159fe38ca12df7d009aa3de472a2e646",
|
|
24
24
|
"src/LawSpec/Gen.hs": "b283001bc18971ddb2159f2ec7e51ac58aa7e191b52577006140694b09a06987",
|
|
25
25
|
"src/LawSpec/Model.hs": "8f501e134cd1480261ae8bb9e3df8255efd38a02eb883468c6bc2c342e200970",
|
|
26
26
|
"src/LawSpec/Parser.hs": "f546502c6eedb0a4ccd30d11e3b017aedf5a7145080ea58cfd34753fd9b509c6",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"wasm/app/Exports.hs": "4ecbdac8faa2449e6fc61b93c82e6278fa14374154f29b4dacf0eef433f06a47",
|
|
31
31
|
"wasm/cabal.project": "021e560afdc5eb4cb7169e7119ecb8f92c9ee170245af909c94b612941bff5cc",
|
|
32
32
|
"wasm/cabal.project.freeze": "733dbed3d2ecccb26e874fd58f136296dad772184deb1658c196b5d54a0814dc",
|
|
33
|
-
"wasm/lawspec-wasm.cabal": "
|
|
34
|
-
"npm/core.wasm": "
|
|
33
|
+
"wasm/lawspec-wasm.cabal": "139de82d2d6063eb82fc86438a82e59d9b9315318009cad199f488bca14cb56d",
|
|
34
|
+
"npm/core.wasm": "943abf2084a7395ef6c5441ef4fd93aa0d57e581a0e71723bf6187afa2c3b48c",
|
|
35
35
|
"npm/core_jsffi.js": "88d136efe92f7cff5758c8fec8d9b6bbc9707fe37741cebeeb415fe34ce3d72b",
|
|
36
36
|
"npm/api.mjs": "d6df654600172131ac66a55b86876fc29cde2a76a0a63bbefff3183488a4837b",
|
|
37
37
|
"npm/index.d.ts": "8003304d88dbb01a07bd3dbdc4d680a193db1ec323c5712b9860e166ca9cc94b"
|
package/core.wasm
CHANGED
|
Binary file
|