lawspec 0.16.0 → 0.17.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/CHANGELOG.md +73 -0
- package/README.md +3 -3
- package/bin/lawspec.mjs +1 -1
- package/build.json +82 -76
- package/core.wasm +0 -0
- package/examples/specs/async_fetch.lawspec +30 -0
- package/examples/specs/collections.lawspec +103 -44
- package/examples/specs/lists.lawspec +67 -0
- package/package.json +1 -1
- package/templates.mjs +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,78 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.17.1
|
|
4
|
+
|
|
5
|
+
### Faster compilation
|
|
6
|
+
|
|
7
|
+
- The compiler reuses work for whatever did not change. A compiler instance
|
|
8
|
+
(one `createCompiler()`, one wasm instance or one process) compiles,
|
|
9
|
+
discharges and plans a set of sources once for every method and target, plans
|
|
10
|
+
each law again only when it or the program's types, declarations, contracts
|
|
11
|
+
or definitions changed, and emits each unit again only when it, its laws or
|
|
12
|
+
that interface changed. Results are identical to a full compile.
|
|
13
|
+
- `lawspec examples` and other multi-target runs compile once instead of once
|
|
14
|
+
per target: generating every bundled example for all eight targets takes
|
|
15
|
+
about 105 seconds instead of about 270.
|
|
16
|
+
- A single compile is faster too: kind lookups use a map instead of scanning
|
|
17
|
+
every type in the program, boundary candidates are deduplicated in
|
|
18
|
+
`n log n`, and long failure messages are split by bisection. Compiling all
|
|
19
|
+
bundled examples together takes a quarter less time.
|
|
20
|
+
|
|
21
|
+
### Incremental local checks
|
|
22
|
+
|
|
23
|
+
- `lawspec-dev ci` records passing results by content. Acceptance suites key
|
|
24
|
+
each run by the generated project and everything else its tests read, so a
|
|
25
|
+
compiler change that leaves a target's output unchanged skips that target's
|
|
26
|
+
native tests. Core steps key by the repository files they read.
|
|
27
|
+
- `lawspec-dev ci --fresh` (`make ci-fresh`) runs every step, and releases use
|
|
28
|
+
it. See [CONTRIBUTING](CONTRIBUTING.md#checks).
|
|
29
|
+
|
|
30
|
+
## 0.17.0
|
|
31
|
+
|
|
32
|
+
### Collections
|
|
33
|
+
|
|
34
|
+
`Set a`, `KeyVal k v`, `Queue a`, `Stack a` and `Deque a` are built in, with
|
|
35
|
+
`Entry k v` and `Ordering`. Operations are total prelude functions, such as
|
|
36
|
+
`prelude.setOf`, `prelude.lookup`, `prelude.push` and `prelude.popBack`, and
|
|
37
|
+
`prelude.compare` orders two keyed values. A unit that declares a type of the
|
|
38
|
+
same name keeps its own.
|
|
39
|
+
|
|
40
|
+
- Set elements and KeyVal keys need the new `Keyed` capability: a total order
|
|
41
|
+
shared by every target. Exact numbers order by value, text by code point,
|
|
42
|
+
lists element by element and data by constructor, then fields. Floats,
|
|
43
|
+
complex numbers and symbols are not keyed.
|
|
44
|
+
- Adapters use each target's own collections: `frozenset` and `dict` in
|
|
45
|
+
Python, `Set` and `Map` in JavaScript, sorted slices in Go, `java.util.Set`
|
|
46
|
+
and `Map` in Java and Kotlin, `BTreeSet` and `BTreeMap` in Rust, and
|
|
47
|
+
`Data.Set` and `Data.Map` in Haskell. Python and JavaScript use sorted tuples
|
|
48
|
+
or arrays where elements are structured. Codecs sort, deduplicate and keep
|
|
49
|
+
the last value for a repeated key.
|
|
50
|
+
- Generated Haskell projects depend on `containers`. Rust and Haskell
|
|
51
|
+
generated data derive `Ord` when it is keyed.
|
|
52
|
+
|
|
53
|
+
See [collections](docs/reference/language/collections.md).
|
|
54
|
+
|
|
55
|
+
### Asynchronous functions
|
|
56
|
+
|
|
57
|
+
`async price :: Text -> Int32` declares an asynchronous adapter. It returns a
|
|
58
|
+
coroutine in Python, a `Promise` in JavaScript and TypeScript, a
|
|
59
|
+
`CompletableFuture` in Java, a `suspend fun` in Kotlin, a goroutine-backed
|
|
60
|
+
`lawspec.Task` in Go, an `IO` action in Haskell and a `Future` in Rust. The
|
|
61
|
+
generated tests await each call where it is made, and check contracts on the
|
|
62
|
+
awaited result. See
|
|
63
|
+
[asynchronous functions](docs/reference/language/async-functions.md).
|
|
64
|
+
|
|
65
|
+
### Other changes
|
|
66
|
+
|
|
67
|
+
- A numeric literal passed to a generic function takes the type its other
|
|
68
|
+
arguments fix: `prelude.insert 1 s` with `s :: Set Int32` needs no
|
|
69
|
+
annotation.
|
|
70
|
+
- Generated schemas no longer revalidate a whole value on each construction,
|
|
71
|
+
match or checked-definition call; values are checked at the adapter
|
|
72
|
+
boundary. Large recursive values test much faster.
|
|
73
|
+
- The list example is now `examples/specs/lists.lawspec`;
|
|
74
|
+
`collections.lawspec` covers the new collections.
|
|
75
|
+
|
|
3
76
|
## 0.16.0
|
|
4
77
|
|
|
5
78
|
### GADTs
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Node 22+ and the selected target's build tools are required. No Haskell
|
|
|
30
30
|
toolchain is needed. The reference platforms are macOS and Linux.
|
|
31
31
|
|
|
32
32
|
```sh
|
|
33
|
-
npm install --save-dev lawspec@0.
|
|
33
|
+
npm install --save-dev lawspec@0.17.1
|
|
34
34
|
npx lawspec --version
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -40,8 +40,8 @@ LawSpec can create `package.json` and its test script:
|
|
|
40
40
|
```sh
|
|
41
41
|
mkdir lawspec-example
|
|
42
42
|
cd lawspec-example
|
|
43
|
-
npm exec --package=lawspec@0.
|
|
44
|
-
npm install --save-dev lawspec@0.
|
|
43
|
+
npm exec --package=lawspec@0.17.1 -- lawspec init --target javascript
|
|
44
|
+
npm install --save-dev lawspec@0.17.1
|
|
45
45
|
npx lawspec check
|
|
46
46
|
npx lawspec explain 'example.atoi_codec::itoa and then atoi yields a'
|
|
47
47
|
npx lawspec doctor
|
package/bin/lawspec.mjs
CHANGED
package/build.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"lawspec.cabal",
|
|
6
6
|
"package.yaml",
|
|
7
7
|
"runtime/LawSpecCodecs.hs",
|
|
8
|
+
"runtime/LawSpecCollectionCodecs.hs",
|
|
8
9
|
"runtime/LawSpecDataStrategies.hs",
|
|
9
10
|
"runtime/LawSpecDataStrategies.java",
|
|
10
11
|
"runtime/LawSpecKotlin.kt",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"src/LawSpec/Capabilities.hs",
|
|
35
36
|
"src/LawSpec/Code/Doc.hs",
|
|
36
37
|
"src/LawSpec/Code/JavaScript.hs",
|
|
38
|
+
"src/LawSpec/Collections.hs",
|
|
37
39
|
"src/LawSpec/Common.hs",
|
|
38
40
|
"src/LawSpec/Compile.hs",
|
|
39
41
|
"src/LawSpec/Core.hs",
|
|
@@ -96,6 +98,7 @@
|
|
|
96
98
|
"src/LawSpec/KotlinNativeBinding.hs",
|
|
97
99
|
"src/LawSpec/KotlinProperties.hs",
|
|
98
100
|
"src/LawSpec/KotlinTestHelpers.hs",
|
|
101
|
+
"src/LawSpec/Memo.hs",
|
|
99
102
|
"src/LawSpec/Model.hs",
|
|
100
103
|
"src/LawSpec/NativeBinding.hs",
|
|
101
104
|
"src/LawSpec/NativeRequest.hs",
|
|
@@ -136,47 +139,49 @@
|
|
|
136
139
|
"wasm/lawspec-wasm.cabal"
|
|
137
140
|
],
|
|
138
141
|
"digests": {
|
|
139
|
-
"dev/Gen/Embed.hs": "
|
|
140
|
-
"lawspec.cabal": "
|
|
141
|
-
"package.yaml": "
|
|
142
|
+
"dev/Gen/Embed.hs": "41cd18500c1a8c9bdb51011ab4c74817f8e04b655aa10d9894aa1b93a3fa858b",
|
|
143
|
+
"lawspec.cabal": "dde1ada13d7a201ea5107f0d042de926ac8d27a00c199af4c46b29c85edc9ba0",
|
|
144
|
+
"package.yaml": "a7f0583e62b8107137d22f89e3c596c0a76c71cfbb14f415a3db3d386c82e58a",
|
|
142
145
|
"runtime/LawSpecCodecs.hs": "1b3f6b40ad49928cf5e9386e06bc2992c9f1271754351b9fa3075e50346ef03b",
|
|
143
|
-
"runtime/
|
|
144
|
-
"runtime/LawSpecDataStrategies.
|
|
146
|
+
"runtime/LawSpecCollectionCodecs.hs": "74caa786801c5142ed040897c7ebb7373abf49ee49e02af53e466646fb624f47",
|
|
147
|
+
"runtime/LawSpecDataStrategies.hs": "9cc5b98476364a6c255dc3eb40c53d65b4a9d4ab0c3961a806b3515a8d5e8f7f",
|
|
148
|
+
"runtime/LawSpecDataStrategies.java": "d06c1eb6c67f3d07ab0c90dc8f8626b48358763b91585c6ea216a47e11886dd0",
|
|
145
149
|
"runtime/LawSpecKotlin.kt": "0cf3b7de0406155225ccca33ee3dfdf8f0456c47d577f6be8f1265c13df838cb",
|
|
146
|
-
"runtime/LawSpecKotlinCodecs.kt": "
|
|
147
|
-
"runtime/LawSpecKotlinStrategies.kt": "
|
|
148
|
-
"runtime/LawSpecRuntime.hs": "
|
|
149
|
-
"runtime/LawSpecRuntime.java": "
|
|
150
|
-
"runtime/LawSpecSchema.hs": "
|
|
151
|
-
"runtime/LawSpecSchema.java": "
|
|
150
|
+
"runtime/LawSpecKotlinCodecs.kt": "416610eb295f2fe0a77dd5a133fc10db081b69a04e1649b33abec60e69f32474",
|
|
151
|
+
"runtime/LawSpecKotlinStrategies.kt": "8ee1edeec1c342f2bc70ca8bdad22ec5aabc38f6f61381fe905b717ffce0688e",
|
|
152
|
+
"runtime/LawSpecRuntime.hs": "59eccad16a99a4118a1f9f51a7556ef133e4b875f2f4f678d394f53cdf03d776",
|
|
153
|
+
"runtime/LawSpecRuntime.java": "8096d2cd35786f4e68991ceef8579337cd3c729f4871c60c261e40a0a4ccc43d",
|
|
154
|
+
"runtime/LawSpecSchema.hs": "c19eedd197fc2359780c1576dd6a1d6e9bcdaf2ed037b5dbb37f3db766356bf9",
|
|
155
|
+
"runtime/LawSpecSchema.java": "67f57d8e91fcf155a443724a5632ef52037a1d67ff12d20f3044cf22d6ca98b2",
|
|
152
156
|
"runtime/LawSpecStrategies.kt": "569f7775c0ac44765d05567cbf62d026558ac193c080ca71681ec6ee49c21794",
|
|
153
|
-
"runtime/lawspec_codecs.go": "
|
|
154
|
-
"runtime/lawspec_data_strategies.go": "
|
|
155
|
-
"runtime/lawspec_data_strategies.mjs": "
|
|
156
|
-
"runtime/lawspec_data_strategies.py": "
|
|
157
|
-
"runtime/lawspec_runtime.go": "
|
|
158
|
-
"runtime/lawspec_runtime.mjs": "
|
|
159
|
-
"runtime/lawspec_runtime.py": "
|
|
160
|
-
"runtime/lawspec_runtime.rs": "
|
|
161
|
-
"runtime/lawspec_schema.go": "
|
|
162
|
-
"runtime/lawspec_schema.mjs": "
|
|
163
|
-
"runtime/lawspec_schema.py": "
|
|
164
|
-
"runtime/lawspec_strategies.rs": "
|
|
165
|
-
"runtime/rust/Cargo.lock": "
|
|
166
|
-
"runtime/rust/Cargo.toml": "
|
|
167
|
-
"src/LawSpec/Api.hs": "
|
|
168
|
-
"src/LawSpec/Backend.hs": "
|
|
169
|
-
"src/LawSpec/Capabilities.hs": "
|
|
157
|
+
"runtime/lawspec_codecs.go": "e069dd6f4331b9bdcbd50dda8fe5faffca83cb9c7c8ea62ac631d2c9fa951bf4",
|
|
158
|
+
"runtime/lawspec_data_strategies.go": "65ca2a09012c516c17bb66d7381637e71f454740858f648a78b9e536f1c7c600",
|
|
159
|
+
"runtime/lawspec_data_strategies.mjs": "5fe9327a6dda2e759558b77100aec96798f1aed4f517d4bc91f45a543b8d14b9",
|
|
160
|
+
"runtime/lawspec_data_strategies.py": "0d06f0c5b9cdd5f6659f424a328884b670c94b1572ec0fa5d5408a05110d94dd",
|
|
161
|
+
"runtime/lawspec_runtime.go": "870e611874d67f45d70c68e03d2094a37f3a12d8a42d9610d8437b8a8d5af30f",
|
|
162
|
+
"runtime/lawspec_runtime.mjs": "bf51f4ebd2855d26d7958cb2ed4ca6f5e8ec6f8a9e31ee38d8324f6accd40b81",
|
|
163
|
+
"runtime/lawspec_runtime.py": "44f69c30040bd9b7df8f66c18fc3487ca965d6eea4f27f811a5ec403a16f9942",
|
|
164
|
+
"runtime/lawspec_runtime.rs": "49e9a13ab742ac5a192785585548c7ab8f8b8f03cb0046ea03acf4b97c2273ee",
|
|
165
|
+
"runtime/lawspec_schema.go": "7e9361e9693c3885d98500026f3e3ef8e213eb72a489a58fc72669e8a9938103",
|
|
166
|
+
"runtime/lawspec_schema.mjs": "d77abea1a9dcb03e4a6c6eef6509971d8599fac9acdefa9b9e4b89b8d0fc5226",
|
|
167
|
+
"runtime/lawspec_schema.py": "daed20d27168970350ef0b63b9cb2e566bd00598922acb4071d863c076e787ba",
|
|
168
|
+
"runtime/lawspec_strategies.rs": "5e991a45548811fef1728e1e9b9f12f76ee4cc7cb9c3339eab79bc4cf5f54f6b",
|
|
169
|
+
"runtime/rust/Cargo.lock": "aaff0a41f104cc53b8ee54ccb66df2a7f6134de526b3a2e4d40a08f71ac4012c",
|
|
170
|
+
"runtime/rust/Cargo.toml": "b42d1d443abac5eda8a05194aa3afc5b06deefe934f61a814d3ee81a7058dee8",
|
|
171
|
+
"src/LawSpec/Api.hs": "b93bc7c1f56cf04a7d1f2be78f1d78511784df09423c67fcc16521ef9ff38738",
|
|
172
|
+
"src/LawSpec/Backend.hs": "caf45afb73e7455dd801195b8b117ca7e4664ac4babc6ef0732e06faf9e64fcb",
|
|
173
|
+
"src/LawSpec/Capabilities.hs": "ab457f3da440a237ee731d664b94d95a0cc1fa4d8be4d4d0403a61ebcf98e310",
|
|
170
174
|
"src/LawSpec/Code/Doc.hs": "9e3b70f85deb1dcbce385af1d0cd4bea2dfa8a2d806d54745d4bb437406673e5",
|
|
171
175
|
"src/LawSpec/Code/JavaScript.hs": "77bf27dcc210216e4739f68c4709f556f80130ab83b3b9387ac4a2421e790910",
|
|
176
|
+
"src/LawSpec/Collections.hs": "f8cc2978b6690709deb421ee22df37985c80e5b06064f819a193d6b912328ee1",
|
|
172
177
|
"src/LawSpec/Common.hs": "107612a8aaa787488413acf9c1a56622004d3bff251db89b99928343e6070883",
|
|
173
|
-
"src/LawSpec/Compile.hs": "
|
|
174
|
-
"src/LawSpec/Core.hs": "
|
|
178
|
+
"src/LawSpec/Compile.hs": "ec8a077041ec65ae908cf5fe48ed3cd15200f613b5cee7a4331f2f0bd9cb66ca",
|
|
179
|
+
"src/LawSpec/Core.hs": "faa5abce4be809298212dee0fbdf1b65c992a950e23801d9509630580e615163",
|
|
175
180
|
"src/LawSpec/Core/DefinitionContracts.hs": "b7f60f038b231187ecf898e585ae1a8fb1fc113bb55bad6d1bb2660350fd969e",
|
|
176
181
|
"src/LawSpec/Core/Definitions.hs": "8e0d1d7127f9d4872f2464b4af50b0f286823d5f0f203baf38fb3c316d766140",
|
|
177
|
-
"src/LawSpec/Core/Eval.hs": "
|
|
178
|
-
"src/LawSpec/Core/Evidence.hs": "
|
|
179
|
-
"src/LawSpec/Core/Expression.hs": "
|
|
182
|
+
"src/LawSpec/Core/Eval.hs": "26c518cf3db1f395f69353cb373e1aacf7f1a0ce81d3e17b15878421e9625a8b",
|
|
183
|
+
"src/LawSpec/Core/Evidence.hs": "48442ab98eafaa0f09d56c01493b73b724845347bbd27ae390c64366faec938d",
|
|
184
|
+
"src/LawSpec/Core/Expression.hs": "8b8a55d6fb166012918f0dc83322776505a83a7024a76c49fc568f29137a3702",
|
|
180
185
|
"src/LawSpec/Core/Payload.hs": "da2417fc99354338eab49a688c5f36cecde5ec1aacd8582c895428568b10a376",
|
|
181
186
|
"src/LawSpec/Core/PayloadPlan.hs": "f2a7d2dc58c6a0f79707bdc24773bd3aad3a3b8eea2735a8284b2a9f3a4af4a8",
|
|
182
187
|
"src/LawSpec/Core/RefinementProof.hs": "c19fc03e68488357a59897ec38ce3d2efd320c35b405b632af17425d6a18447a",
|
|
@@ -184,92 +189,93 @@
|
|
|
184
189
|
"src/LawSpec/Core/Semantics.hs": "cdb8256e523f7808fa50fe7d80d709217a28de4c81c5ff5be8382f94900f3779",
|
|
185
190
|
"src/LawSpec/Core/Total.hs": "308684d7ff78a5e4dc75aef30c4df17610a2cb107d48ddb75d14d8573b178e5b",
|
|
186
191
|
"src/LawSpec/Core/Totality.hs": "5e76100466cf4a157b9eda36738806af836a5bda949f5d568d7bf5155fa8858a",
|
|
187
|
-
"src/LawSpec/Core/Types.hs": "
|
|
192
|
+
"src/LawSpec/Core/Types.hs": "04d9c093fcc0d84e2864c8a3b69d5fe318a92c60b32844048198f1b12fe1b6fb",
|
|
188
193
|
"src/LawSpec/Core/Validate.hs": "74c2a51eb913f8414268064f22d2d5d97ebfb0e4797e146b229076c29ac38726",
|
|
189
|
-
"src/LawSpec/Core/Value.hs": "
|
|
190
|
-
"src/LawSpec/CoreEmit.hs": "
|
|
191
|
-
"src/LawSpec/CoreNativeScalarEmit.hs": "
|
|
192
|
-
"src/LawSpec/CoreScalarEmit.hs": "
|
|
194
|
+
"src/LawSpec/Core/Value.hs": "a1e0745154c54498d7e164a89546ef2a56afade05a1d362e1c63986245ad2774",
|
|
195
|
+
"src/LawSpec/CoreEmit.hs": "da5577b7022315df25a76b41911840f98174025cd4ce96f4c51dfadb4eb7302c",
|
|
196
|
+
"src/LawSpec/CoreNativeScalarEmit.hs": "5a5d145a18f596682a3dc3dacb009268d48c384c2f2ca620b503268096a66940",
|
|
197
|
+
"src/LawSpec/CoreScalarEmit.hs": "0493aa132599aca36a773717252281c2ab9c2aeb6ac1c90269dfbea50aaa36b1",
|
|
193
198
|
"src/LawSpec/Data.hs": "f659f4e86f1009c4806334a45686970dde2efa2641585f997a7beba01d0e6f2d",
|
|
194
199
|
"src/LawSpec/DataNames.hs": "2eeb0d215131981a2271725a50c21dce44c7146a167025eb239a83922fdecaf6",
|
|
195
|
-
"src/LawSpec/DefinitionTotality.hs": "
|
|
200
|
+
"src/LawSpec/DefinitionTotality.hs": "adf00236e0e1b1cad4299793ced5f9047dbc2321d3c2f9ba040bac30d1a87c73",
|
|
196
201
|
"src/LawSpec/Discharge.hs": "bd1acbddecf1f060aaaad1a6796825321c56b434d556e9873eb6c9d99459fdb7",
|
|
197
202
|
"src/LawSpec/Domain.hs": "222d15f0012ae630802238a6d7e1ee78d1e718b599f5ebb5a1ddc4e8d29d68c3",
|
|
198
203
|
"src/LawSpec/DomainModel.hs": "835e6e31c9565bd624c1139ead71ad65c1065ee660457ae365522f7ed78f7939",
|
|
199
|
-
"src/LawSpec/Elaboration.hs": "
|
|
204
|
+
"src/LawSpec/Elaboration.hs": "aade19ada1b9b944d1d5864b1ada61f89a57a675d7e8de9e2f3bc6b6f6d84b00",
|
|
200
205
|
"src/LawSpec/Emit.hs": "9f34f5765915a2a12a66a6dca647ddaef9289372956802c6d99cf0cfec447c7a",
|
|
201
206
|
"src/LawSpec/Eval.hs": "b87a786ed7a512c60e00a037a1a36738933518aafa255babaa8b1b42dbb8ff6d",
|
|
202
207
|
"src/LawSpec/Flow.hs": "830b9d59b94f26a05687bd5baed06b4ecbf1f47c6a634766810d3dd2a44647cd",
|
|
203
208
|
"src/LawSpec/Frontend.hs": "5f2bb4f3580b8fca6d899a0b40000da653fb7e76f11f8c8df271eb023ad5b278",
|
|
204
|
-
"src/LawSpec/GoData.hs": "
|
|
205
|
-
"src/LawSpec/GoDefinitions.hs": "
|
|
206
|
-
"src/LawSpec/GoExpr.hs": "
|
|
209
|
+
"src/LawSpec/GoData.hs": "ffd2f91688e4efdbd65033b88ad55032278f9b29d8027f6dc9e4b2c3eb9bfbc0",
|
|
210
|
+
"src/LawSpec/GoDefinitions.hs": "907fb5ba9935391fa640c0cf6d037db78d270467a8b93e1190a9d511f03561ff",
|
|
211
|
+
"src/LawSpec/GoExpr.hs": "67ef004e97074976e0fd137dfef8d417efe8de3f7d5c3c08293874d30d89e9d0",
|
|
207
212
|
"src/LawSpec/GoNativeBinding.hs": "1ad8ea4cec6187c7e6005651c0edeec69e196eb329fb958c833da7751225aa1b",
|
|
208
|
-
"src/LawSpec/GoProperties.hs": "
|
|
213
|
+
"src/LawSpec/GoProperties.hs": "a6118510ae472de8cbeb0f1dfb025f23a84123bccc5a53af20ad39470851e639",
|
|
209
214
|
"src/LawSpec/GoTestHelpers.hs": "dee55ee8505370e932773b8c685f4a1f380129e6f43f8806bf1e82efb99451b1",
|
|
210
215
|
"src/LawSpec/GoTypeRefs.hs": "7f239f5ac3ac8bd21c8f76c328049f7715d8562ee1382befa0a58abd4f15f726",
|
|
211
|
-
"src/LawSpec/HaskellData.hs": "
|
|
212
|
-
"src/LawSpec/HaskellDefinitions.hs": "
|
|
213
|
-
"src/LawSpec/HaskellExpr.hs": "
|
|
216
|
+
"src/LawSpec/HaskellData.hs": "8ca1f1a353972a28b3d044c3763243cd8a2abf3e2cdb3b15b6112d8a7edf9da2",
|
|
217
|
+
"src/LawSpec/HaskellDefinitions.hs": "9481901b9f1753dbfe90dcc859275eaab474acdb2f41035cd14e9d03cce45440",
|
|
218
|
+
"src/LawSpec/HaskellExpr.hs": "f7ef064ac6700c027de4bd71bddeb3236853232cf7a39bed61de16153539b401",
|
|
214
219
|
"src/LawSpec/HaskellNativeBinding.hs": "9f98aa0c8659b572bd6486a0e29c4692bc6432db8639fa74a09bbf1b771bbfa6",
|
|
215
|
-
"src/LawSpec/HaskellProperties.hs": "
|
|
220
|
+
"src/LawSpec/HaskellProperties.hs": "3f99a4083b602e3a197446614f66f127384b2babd6039c5d3189a81c75329db4",
|
|
216
221
|
"src/LawSpec/HaskellTestHelpers.hs": "51e59b2abc9e85455e3c8e2c6baadb27e5d319081cb730d2ce56be5dc8053897",
|
|
217
222
|
"src/LawSpec/HaskellTypeRefs.hs": "2225b2a5e2ab3662e7202d23b24f4d6db48353b35ae28df8acd2b92fd2b97574",
|
|
218
|
-
"src/LawSpec/Imports.hs": "
|
|
223
|
+
"src/LawSpec/Imports.hs": "1182894623b69e777531706c013b5ecd9995c51dd8c8b969c1807a5a103bf2da",
|
|
219
224
|
"src/LawSpec/IndexTerm.hs": "65e7942306f08683ec9f284f76b10ad271f8a909b1ec721da04f6275c9a1d20e",
|
|
220
225
|
"src/LawSpec/Indexed.hs": "1e7ed53653cabc097f75dcf350c81facf9feb30af73f3e21f9344665fc316387",
|
|
221
|
-
"src/LawSpec/Inference.hs": "
|
|
222
|
-
"src/LawSpec/JavaData.hs": "
|
|
223
|
-
"src/LawSpec/JavaDefinitions.hs": "
|
|
224
|
-
"src/LawSpec/JavaExpr.hs": "
|
|
226
|
+
"src/LawSpec/Inference.hs": "8d3a8853bd691329d6d1cf0cdde9e4e8f8c895f5be944f2e77e9df348d1aa0eb",
|
|
227
|
+
"src/LawSpec/JavaData.hs": "8afc712aed51240921cd6830b5d21ab029f71cc5cb0de56ca522eadd94ccb600",
|
|
228
|
+
"src/LawSpec/JavaDefinitions.hs": "ba771b59878d8780613d1d40094597e8dca0478ccde11188a39df77667a01dab",
|
|
229
|
+
"src/LawSpec/JavaExpr.hs": "fb1d3e64f3288e557720dead7738eb4f2a59d4563e5be4a742e1582829f19d3e",
|
|
225
230
|
"src/LawSpec/JavaNativeBinding.hs": "9eb52b3be19badda078069bb3d6813d72cad4f0a9bfa708f7404e44201d3c352",
|
|
226
|
-
"src/LawSpec/JavaProperties.hs": "
|
|
231
|
+
"src/LawSpec/JavaProperties.hs": "7438793af96d9e9e2072670c4bc20f56729c85e054d598b5ad4e991bfdf094a1",
|
|
227
232
|
"src/LawSpec/JavaTestHelpers.hs": "e6f4b9bbb7e5f07ece6ab1845e12aa661e62e8b926680b11454223fc3ec1523d",
|
|
228
|
-
"src/LawSpec/KotlinData.hs": "
|
|
233
|
+
"src/LawSpec/KotlinData.hs": "ca3bad4dca9fcd604cd39ec713ef8ed38966aaf24b1d6b33d88d405bfc80641d",
|
|
229
234
|
"src/LawSpec/KotlinDefinitions.hs": "97d7d407d4bbdb4ce16035d607dbbcb8e3d6f5db513f2123a2c269e3dc6d2b38",
|
|
230
235
|
"src/LawSpec/KotlinExpr.hs": "20312f0774f1d0832a21a19b93c8103e2791ecd32a827d8e9c4f2b4830a996a0",
|
|
231
236
|
"src/LawSpec/KotlinNativeBinding.hs": "1aec7854758f07a4d2288de13931fbb88ef32220f85d3c84fe8233ad67b6d095",
|
|
232
|
-
"src/LawSpec/KotlinProperties.hs": "
|
|
237
|
+
"src/LawSpec/KotlinProperties.hs": "5c7289c97cc915cbc3432eb4b08a2fefbe786af4d6591af4b59923aa9d6a2075",
|
|
233
238
|
"src/LawSpec/KotlinTestHelpers.hs": "74810d65faafc6ed4d64b1fb0596cda4186e586b7144a7441641b798795bc324",
|
|
234
|
-
"src/LawSpec/
|
|
239
|
+
"src/LawSpec/Memo.hs": "35a0d0f2ebcf649771dd418c3609fd3c1fc9bfe7f787ffe64102cc6dab9f0fc6",
|
|
240
|
+
"src/LawSpec/Model.hs": "72fae874b4a5aa98057254fc1b508df3f71ec8587740bc7c18ea29490526137b",
|
|
235
241
|
"src/LawSpec/NativeBinding.hs": "33959b0fd432ad4150f3b685f6438e284b801c2a59d9ef3132486a1cc7c8925a",
|
|
236
|
-
"src/LawSpec/NativeRequest.hs": "
|
|
242
|
+
"src/LawSpec/NativeRequest.hs": "f8200c36725859ea32374655951f7a45e2b3342b159f9f6c88b5f9a2a6331897",
|
|
237
243
|
"src/LawSpec/Packages.hs": "161fc68a9959a80762ca4ece405240351e3180ea4dbb2bf148eaca6562fb7c30",
|
|
238
|
-
"src/LawSpec/Parser.hs": "
|
|
244
|
+
"src/LawSpec/Parser.hs": "953e907c51e12724085a6ce0504c767a8d622acf7ad4479913ed2cb86017251e",
|
|
239
245
|
"src/LawSpec/PortableGenerator.hs": "69d457e39f539c77fc7a4c08205e75352bbecd9dfdff031a283a39bf44b22d49",
|
|
240
|
-
"src/LawSpec/PortableTestHelpers.hs": "
|
|
246
|
+
"src/LawSpec/PortableTestHelpers.hs": "8d98184c92a34b431f2a820cef3ea735b0cec3a52504f519b3bb06cb5174017c",
|
|
241
247
|
"src/LawSpec/Prelude.hs": "b1e155c12f58e7c346551a0c65c5d5af76d045b3f1625977ca2a5d1c97cb8c46",
|
|
242
|
-
"src/LawSpec/Public.hs": "
|
|
243
|
-
"src/LawSpec/PythonData.hs": "
|
|
244
|
-
"src/LawSpec/PythonDefinitions.hs": "
|
|
248
|
+
"src/LawSpec/Public.hs": "7010357e250607a9f94d1ab8dc34fad4014fb7d9f15ba0d7c2fc94d0f48fcac4",
|
|
249
|
+
"src/LawSpec/PythonData.hs": "bb6e947829aa7611f39fb74152e8ef013c192be717a3573f12d249973ca65e5d",
|
|
250
|
+
"src/LawSpec/PythonDefinitions.hs": "387a3f7678a7968249805365602206ebc0bb8d5b56924534d35294a1a98b0e5f",
|
|
245
251
|
"src/LawSpec/PythonExpr.hs": "23d7d24b5fb4efff9cb63d38c02a93d95744ec79b4565daf1412088fc7c4ba59",
|
|
246
252
|
"src/LawSpec/PythonNativeBinding.hs": "4e35ff8781062d0f614e45ea45f98038c8d609ab78bd671cb0a239eaa9db1690",
|
|
247
|
-
"src/LawSpec/PythonTypes.hs": "
|
|
253
|
+
"src/LawSpec/PythonTypes.hs": "d465eef5fecef5d011fa422655d51cd1123800a39cfaf042545d41f2557bd98c",
|
|
248
254
|
"src/LawSpec/Refinement.hs": "3bbdc090f9ebce60d99254dbe93dec6e11bd838df8537df828fd9c768c79d126",
|
|
249
|
-
"src/LawSpec/RuntimeSources.hs": "
|
|
250
|
-
"src/LawSpec/RustData.hs": "
|
|
251
|
-
"src/LawSpec/RustDefinitions.hs": "
|
|
252
|
-
"src/LawSpec/RustEmit.hs": "
|
|
255
|
+
"src/LawSpec/RuntimeSources.hs": "b984cd8635be4109ea79fff5becb9accb1379f5322aaf6c50938264f01ba47b6",
|
|
256
|
+
"src/LawSpec/RustData.hs": "b8bb35f2cc5835c811e01e8bbbe172f483ab2620e1e8e331cdfaf6342c23e7f1",
|
|
257
|
+
"src/LawSpec/RustDefinitions.hs": "8211ad8c4db088ae658918b5172a666303aaf1bfe3f29bdd0b520a77015b2892",
|
|
258
|
+
"src/LawSpec/RustEmit.hs": "a57aaef4f6980a4d00b6fee1caf099b5ee317f1f8f6cfc9c480f68a431d39942",
|
|
253
259
|
"src/LawSpec/RustExpr.hs": "04b2ef81417b811c7b98a98acdadab4e588ca8757964a63ba8dc5936c36479e6",
|
|
254
260
|
"src/LawSpec/RustNativeBinding.hs": "d50d1fb10591ee86129ae49b38a343148c084479e450eef3b320e1efdd55245d",
|
|
255
261
|
"src/LawSpec/RustNativeGenerators.hs": "a3b1484d9ff0008e4f961aa81d0aa51da57ec0cd7909124e80c98d56aacc8ce9",
|
|
256
|
-
"src/LawSpec/Scaffold.hs": "
|
|
257
|
-
"src/LawSpec/Scalar.hs": "
|
|
262
|
+
"src/LawSpec/Scaffold.hs": "217328445923b9e339428dd542ce9b910c26ed132c31d1ef083de73763b749f9",
|
|
263
|
+
"src/LawSpec/Scalar.hs": "c49180c9de3d9549dbfa715a0e21868badc2ea78357381be883026c71b477a44",
|
|
258
264
|
"src/LawSpec/SpecializeDefinitions.hs": "2bdd6d9b191941d869ef524659e02fed551499aaa2ea98c99323da03af113012",
|
|
259
|
-
"src/LawSpec/Testing.hs": "
|
|
260
|
-
"src/LawSpec/WebData.hs": "
|
|
261
|
-
"src/LawSpec/WebDefinitions.hs": "
|
|
265
|
+
"src/LawSpec/Testing.hs": "1e0dcbfad6f504ad232ac846299be736492aec73239ee9918c4e8266baa47248",
|
|
266
|
+
"src/LawSpec/WebData.hs": "bbcd7d734ce3941d83cc455a9a2147b642f6111ebb34db9ef99dcb7a58b8c4ae",
|
|
267
|
+
"src/LawSpec/WebDefinitions.hs": "579309c76b9303a3c9e456e1252f2d0881795210aa0b09104a00efdfe10e3e13",
|
|
262
268
|
"src/LawSpec/WebExpr.hs": "0389dcd5cf7479dd23ef034b1012de6ebd70bf1dc9e3d90981dfb0ba2702596f",
|
|
263
269
|
"src/LawSpec/WebNativeBinding.hs": "f536c1b1454bc83f5a9e8c61a608390b9a6fa91537f34d3c245b90ee6e275b7d",
|
|
264
|
-
"src/LawSpec/WebTypes.hs": "
|
|
270
|
+
"src/LawSpec/WebTypes.hs": "1d43194e4dafbdcbed6e607414a875e9030028f03579f17d189c14a6a9bd5e53",
|
|
265
271
|
"src/LawSpec/Witness.hs": "9ae944c9307df964bc853205269c1e4cb69cc076070bb878fc957f4bdb02de85",
|
|
266
272
|
"stack.yaml": "20ccf4d599e355e60b7aa4f814a7cd4299fe2048616cc2e6dbdc22a7bd8cec73",
|
|
267
273
|
"stack.yaml.lock": "ae222b9c81af920c56e50fa4596fa57786e7fa5a7b461390362b2b2ff63818c7",
|
|
268
274
|
"wasm/app/Exports.hs": "4ecbdac8faa2449e6fc61b93c82e6278fa14374154f29b4dacf0eef433f06a47",
|
|
269
275
|
"wasm/cabal.project": "021e560afdc5eb4cb7169e7119ecb8f92c9ee170245af909c94b612941bff5cc",
|
|
270
276
|
"wasm/cabal.project.freeze": "733dbed3d2ecccb26e874fd58f136296dad772184deb1658c196b5d54a0814dc",
|
|
271
|
-
"wasm/lawspec-wasm.cabal": "
|
|
272
|
-
"npm/core.wasm": "
|
|
277
|
+
"wasm/lawspec-wasm.cabal": "c624549c098df60abe2d1e83e4a69e1d311d7a73ba53e2174944f8814dd3d139",
|
|
278
|
+
"npm/core.wasm": "9d5d3b367cdbe95924f20580b3638332b5f4a0e828b90ab3c01812422637ee00",
|
|
273
279
|
"npm/core_jsffi.js": "88d136efe92f7cff5758c8fec8d9b6bbc9707fe37741cebeeb415fe34ce3d72b",
|
|
274
280
|
"npm/api.mjs": "19e1624f91258c1397f3212faf65b407c62671b0fc5b118520e6a91f7ad7c6ba",
|
|
275
281
|
"npm/index.d.ts": "2215087cc6628a2ddbdd573210c4f9021cffeb00c142d4f3ae1314fd59a397f6"
|
package/core.wasm
CHANGED
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
unit example.orders
|
|
2
|
+
|
|
3
|
+
-- An async adapter's result arrives later, as the target's task (a coroutine,
|
|
4
|
+
-- Promise, CompletableFuture, suspend call, Go task, IO action or Future); the
|
|
5
|
+
-- tests await each call where it is made, in order.
|
|
6
|
+
|
|
7
|
+
-- A product's price, looked up remotely. Prices are never negative.
|
|
8
|
+
async price :: (sku :: Text) -> (r :: Int32 where r >= 0)
|
|
9
|
+
-- How many are in stock.
|
|
10
|
+
async stock :: Text -> Int32
|
|
11
|
+
-- A local quote of the same price.
|
|
12
|
+
quote :: Text -> Int32
|
|
13
|
+
|
|
14
|
+
law `prices agree with quotes` is
|
|
15
|
+
definition is `for all` (sku :: Text) . price sku = quote sku end
|
|
16
|
+
example `a free sample` is
|
|
17
|
+
sku = "free"
|
|
18
|
+
expect price sku = 0
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
-- Two awaited calls in one clause.
|
|
23
|
+
law `stock never lowers a price` is
|
|
24
|
+
definition is `for all` (sku :: Text) . price sku + stock sku >= stock sku end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
-- An awaited call in a guard.
|
|
28
|
+
law `stocked products have prices` is
|
|
29
|
+
definition is `for all` (sku :: Text) . stock sku > 0 implies price sku >= 0 end
|
|
30
|
+
end
|
|
@@ -1,67 +1,126 @@
|
|
|
1
1
|
unit example.collections
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
-- Built-in collections: Set and KeyVal keep their elements and keys in the
|
|
4
|
+
-- portable total order, without repeats; Queue, Stack and Deque keep their
|
|
5
|
+
-- items in order. prelude.setOf, keyValOf, queueOf, stackOf and dequeOf
|
|
6
|
+
-- build them from lists.
|
|
7
|
+
|
|
8
|
+
-- The distinct values of a list.
|
|
9
|
+
dedupe :: List Int32 -> Set Int32
|
|
10
|
+
-- How many times each word occurs.
|
|
11
|
+
wordCounts :: List Text -> KeyVal Text BigInt
|
|
12
|
+
-- Enqueue every value, first to last.
|
|
13
|
+
fifo :: List Int8 -> Queue Int8
|
|
14
|
+
-- Push every value, first to last: the last is on top.
|
|
15
|
+
lifo :: List Int8 -> Stack Int8
|
|
16
|
+
-- Move the front item to the back.
|
|
17
|
+
rotate :: Deque Int8 -> Deque Int8
|
|
18
|
+
-- The distinct lists among some lists: structured elements.
|
|
19
|
+
distinctRows :: List (List Int8) -> Set (List Int8)
|
|
20
|
+
|
|
21
|
+
definition countWords (words :: List Text) (counts :: KeyVal Text BigInt) :: KeyVal Text BigInt is
|
|
22
|
+
match words with
|
|
23
|
+
| Nil -> counts
|
|
24
|
+
| Cons w rest -> match prelude.lookup w counts with
|
|
25
|
+
| Nothing -> countWords rest (prelude.put w 1 counts)
|
|
26
|
+
| Just n -> countWords rest (prelude.put w ((n + 1) :: BigInt) counts)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
definition rotated (d :: Deque Int8) :: Deque Int8 is
|
|
32
|
+
match prelude.peekFront d with
|
|
33
|
+
| Nothing -> d
|
|
34
|
+
| Just x -> prelude.pushBack x (prelude.popFront d)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
law `dedupe agrees with setOf` is
|
|
39
|
+
definition is `for all` (xs :: List Int32) . dedupe xs = prelude.setOf xs end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
law `distinct rows agree with setOf` is
|
|
43
|
+
definition is `for all` (rows :: List (List Int8)) . distinctRows rows = prelude.setOf rows end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
law `word counts agree with the definition` is
|
|
47
|
+
definition is
|
|
48
|
+
`for all` (words :: List Text) . wordCounts words = countWords words (prelude.keyValOf [])
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
law `the queue's front is the first value` is
|
|
53
|
+
definition is
|
|
54
|
+
`for all` (x :: Int8) (xs :: List Int8) . prelude.front (fifo (Cons x xs)) = Just x
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
law `the stack's top is the last value` is
|
|
59
|
+
definition is
|
|
60
|
+
`for all` (x :: Int8) (xs :: List Int8) . prelude.peek (lifo [x]) = Just x
|
|
20
61
|
end
|
|
21
|
-
example `empty input` is x = [] expect reverse x = [] end
|
|
22
62
|
end
|
|
23
63
|
|
|
24
|
-
law `
|
|
25
|
-
definition is `
|
|
26
|
-
example `duplicates` is x = [3, 1, 3] expect sort x = [1, 3, 3] end
|
|
64
|
+
law `fifo keeps the order` is
|
|
65
|
+
definition is `for all` (xs :: List Int8) . prelude.toList (fifo xs) = xs end
|
|
27
66
|
end
|
|
28
67
|
|
|
29
|
-
law `
|
|
30
|
-
definition is `for all` (
|
|
68
|
+
law `rotate agrees with the definition` is
|
|
69
|
+
definition is `for all` (d :: Deque Int8) . rotate d = rotated d end
|
|
31
70
|
end
|
|
32
71
|
|
|
33
|
-
law `
|
|
34
|
-
definition is
|
|
72
|
+
law `union is commutative` is
|
|
73
|
+
definition is
|
|
74
|
+
`for all` (s :: Set Int32) (t :: Set Int32) . prelude.union s t = prelude.union t s
|
|
75
|
+
end
|
|
35
76
|
end
|
|
36
77
|
|
|
37
|
-
law `
|
|
38
|
-
definition is
|
|
78
|
+
law `a removed value is no member` is
|
|
79
|
+
definition is
|
|
80
|
+
`for all` (x :: Int32) (s :: Set Int32) . prelude.member x (prelude.remove x s) = false
|
|
81
|
+
end
|
|
39
82
|
end
|
|
40
83
|
|
|
41
|
-
law `
|
|
84
|
+
law `an inserted value is a member` is
|
|
42
85
|
definition is
|
|
43
|
-
`for all` (
|
|
44
|
-
prelude.length (reverse xs) = prelude.length xs
|
|
86
|
+
`for all` (x :: Int32) (s :: Set Int32) . prelude.member x (prelude.insert x s) = true
|
|
45
87
|
end
|
|
46
88
|
end
|
|
47
89
|
|
|
48
|
-
law `
|
|
49
|
-
definition is
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
90
|
+
law `intersection and difference split a set` is
|
|
91
|
+
definition is
|
|
92
|
+
`for all` (s :: Set Int32) (t :: Set Int32) .
|
|
93
|
+
prelude.union (prelude.intersection s t) (prelude.difference s t) = s
|
|
94
|
+
end
|
|
53
95
|
end
|
|
54
96
|
|
|
55
|
-
law `
|
|
56
|
-
definition is
|
|
57
|
-
|
|
58
|
-
|
|
97
|
+
law `the latest put wins` is
|
|
98
|
+
definition is
|
|
99
|
+
`for all` (k :: Text) (v :: BigInt) (w :: BigInt) (m :: KeyVal Text BigInt) .
|
|
100
|
+
prelude.lookup k (prelude.put k w (prelude.put k v m)) = Just w
|
|
101
|
+
end
|
|
59
102
|
end
|
|
60
103
|
|
|
61
|
-
law `
|
|
62
|
-
definition is
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
104
|
+
law `a deleted key is absent` is
|
|
105
|
+
definition is
|
|
106
|
+
`for all` (k :: Text) (m :: KeyVal Text BigInt) . prelude.lookup k (prelude.delete k m) = Nothing
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
law `keys are distinct` is
|
|
111
|
+
definition is
|
|
112
|
+
`for all` (m :: KeyVal Text BigInt) . prelude.size (prelude.setOf (prelude.keys m)) = prelude.size m
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
law `popping the back leaves the rest` is
|
|
117
|
+
definition is
|
|
118
|
+
`for all` (x :: Int8) (d :: Deque Int8) . prelude.popBack (prelude.pushBack x d) = d
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
law `the empty stack stays empty` is
|
|
123
|
+
definition is
|
|
124
|
+
`for all` (x :: Int8) . prelude.isEmpty (prelude.pop (prelude.stackOf [x])) = true
|
|
66
125
|
end
|
|
67
126
|
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
unit example.lists
|
|
2
|
+
|
|
3
|
+
reverse :: List Int32 -> List Int32
|
|
4
|
+
sort :: List Int32 -> List Int32
|
|
5
|
+
sorted :: List Int32 -> Bool
|
|
6
|
+
permutation :: List Int32 -> List Int32 -> Bool
|
|
7
|
+
echoMaybe :: Maybe (Maybe Bool) -> Maybe (Maybe Bool)
|
|
8
|
+
echoEither :: Either (List Int32) (Maybe Bool) -> Either (List Int32) (Maybe Bool)
|
|
9
|
+
echoNested :: List (Maybe (Either CodeUnit16 Bytes)) -> List (Maybe (Either CodeUnit16 Bytes))
|
|
10
|
+
|
|
11
|
+
law `list involution` (f :: List a -> List a) requires Eq a is
|
|
12
|
+
definition is `involution` f end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
law `reverse twice restores the list` is
|
|
16
|
+
definition is `list involution` reverse end
|
|
17
|
+
example `ordered input` is
|
|
18
|
+
x = [3, 1, 2]
|
|
19
|
+
expect reverse x = [2, 1, 3]
|
|
20
|
+
end
|
|
21
|
+
example `empty input` is x = [] expect reverse x = [] end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
law `sorting is idempotent` is
|
|
25
|
+
definition is `idempotent` sort end
|
|
26
|
+
example `duplicates` is x = [3, 1, 3] expect sort x = [1, 3, 3] end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
law `sort produces sorted output` is
|
|
30
|
+
definition is `for all` (xs :: List Int32) . sorted (sort xs) end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
law `sort preserves length` is
|
|
34
|
+
definition is `for all` (xs :: List Int32) . prelude.length (sort xs) = prelude.length xs end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
law `sort preserves elements` is
|
|
38
|
+
definition is `for all` (xs :: List Int32) . permutation (sort xs) xs end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
law `nonempty reversal preserves length` is
|
|
42
|
+
definition is
|
|
43
|
+
`for all` (xs :: List Int32 where prelude.length xs > 0) .
|
|
44
|
+
prelude.length (reverse xs) = prelude.length xs
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
law `Maybe preserves nested absence` is
|
|
49
|
+
definition is `for all` (x :: Maybe (Maybe Bool)) . echoMaybe x = x end
|
|
50
|
+
example `outer absence` is x = Nothing expect echoMaybe x = Nothing end
|
|
51
|
+
example `inner absence` is x = Just Nothing expect echoMaybe x = Just Nothing end
|
|
52
|
+
example `present` is x = Just (Just true) expect echoMaybe x = Just (Just true) end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
law `Either preserves branches` is
|
|
56
|
+
definition is `for all` (x :: Either (List Int32) (Maybe Bool)) . echoEither x = x end
|
|
57
|
+
example `left list` is x = Left [3, 1, 3] expect echoEither x = Left [3, 1, 3] end
|
|
58
|
+
example `right absence` is x = Right Nothing expect echoEither x = Right Nothing end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
law `nested raw values survive` is
|
|
62
|
+
definition is `for all` (xs :: List (Maybe (Either CodeUnit16 Bytes))) . echoNested xs = xs end
|
|
63
|
+
example `surrogate and octets` is
|
|
64
|
+
xs = [Nothing, Just (Left codeUnit16(55296)), Just (Right bytes([0, 255]))]
|
|
65
|
+
expect echoNested xs = [Nothing, Just (Left codeUnit16(55296)), Just (Right bytes([0, 255]))]
|
|
66
|
+
end
|
|
67
|
+
end
|
package/package.json
CHANGED
package/templates.mjs
CHANGED
|
@@ -81,12 +81,12 @@ const scaffolds = {
|
|
|
81
81
|
"haskell": {
|
|
82
82
|
"readable": {
|
|
83
83
|
"stack.yaml": "snapshot: lts-24.58\npackages: [.]\n",
|
|
84
|
-
"package.yaml": "name: lawspec-example\nversion: 0.1.0\ndependencies: [base, text, bytestring]\nlibrary:\n source-dirs: src\ntests:\n laws:\n main: Spec.hs\n source-dirs: test\n dependencies: [lawspec-example, hspec, hedgehog, hspec-hedgehog, containers, mtl]\n build-tools: [hspec-discover]\n",
|
|
84
|
+
"package.yaml": "name: lawspec-example\nversion: 0.1.0\ndependencies: [base, text, bytestring, containers]\nlibrary:\n source-dirs: src\ntests:\n laws:\n main: Spec.hs\n source-dirs: test\n dependencies: [lawspec-example, hspec, hedgehog, hspec-hedgehog, containers, mtl]\n build-tools: [hspec-discover]\n",
|
|
85
85
|
"test/Spec.hs": "{-# OPTIONS_GHC -F -pgmF hspec-discover #-}\n"
|
|
86
86
|
},
|
|
87
87
|
"compact": {
|
|
88
88
|
"stack.yaml": "snapshot: lts-24.58\npackages: [.]\n",
|
|
89
|
-
"package.yaml": "name: lawspec-example\nversion: 0.1.0\ndependencies: [base, text, bytestring]\nlibrary:\n source-dirs: src\ntests:\n laws:\n main: Spec.hs\n source-dirs: test\n dependencies: [lawspec-example, hspec, hedgehog, hspec-hedgehog, containers, mtl]\n build-tools: [hspec-discover]\n",
|
|
89
|
+
"package.yaml": "name: lawspec-example\nversion: 0.1.0\ndependencies: [base, text, bytestring, containers]\nlibrary:\n source-dirs: src\ntests:\n laws:\n main: Spec.hs\n source-dirs: test\n dependencies: [lawspec-example, hspec, hedgehog, hspec-hedgehog, containers, mtl]\n build-tools: [hspec-discover]\n",
|
|
90
90
|
"test/Spec.hs": "{-# OPTIONS_GHC -F -pgmF hspec-discover #-}\n"
|
|
91
91
|
}
|
|
92
92
|
},
|