lawspec 0.16.0 → 0.17.0
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 +46 -0
- package/README.md +3 -3
- package/bin/lawspec.mjs +1 -1
- package/build.json +78 -74
- 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,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Collections
|
|
6
|
+
|
|
7
|
+
`Set a`, `KeyVal k v`, `Queue a`, `Stack a` and `Deque a` are built in, with
|
|
8
|
+
`Entry k v` and `Ordering`. Operations are total prelude functions, such as
|
|
9
|
+
`prelude.setOf`, `prelude.lookup`, `prelude.push` and `prelude.popBack`, and
|
|
10
|
+
`prelude.compare` orders two keyed values. A unit that declares a type of the
|
|
11
|
+
same name keeps its own.
|
|
12
|
+
|
|
13
|
+
- Set elements and KeyVal keys need the new `Keyed` capability: a total order
|
|
14
|
+
shared by every target. Exact numbers order by value, text by code point,
|
|
15
|
+
lists element by element and data by constructor, then fields. Floats,
|
|
16
|
+
complex numbers and symbols are not keyed.
|
|
17
|
+
- Adapters use each target's own collections: `frozenset` and `dict` in
|
|
18
|
+
Python, `Set` and `Map` in JavaScript, sorted slices in Go, `java.util.Set`
|
|
19
|
+
and `Map` in Java and Kotlin, `BTreeSet` and `BTreeMap` in Rust, and
|
|
20
|
+
`Data.Set` and `Data.Map` in Haskell. Python and JavaScript use sorted tuples
|
|
21
|
+
or arrays where elements are structured. Codecs sort, deduplicate and keep
|
|
22
|
+
the last value for a repeated key.
|
|
23
|
+
- Generated Haskell projects depend on `containers`. Rust and Haskell
|
|
24
|
+
generated data derive `Ord` when it is keyed.
|
|
25
|
+
|
|
26
|
+
See [collections](docs/reference/language/collections.md).
|
|
27
|
+
|
|
28
|
+
### Asynchronous functions
|
|
29
|
+
|
|
30
|
+
`async price :: Text -> Int32` declares an asynchronous adapter. It returns a
|
|
31
|
+
coroutine in Python, a `Promise` in JavaScript and TypeScript, a
|
|
32
|
+
`CompletableFuture` in Java, a `suspend fun` in Kotlin, a goroutine-backed
|
|
33
|
+
`lawspec.Task` in Go, an `IO` action in Haskell and a `Future` in Rust. The
|
|
34
|
+
generated tests await each call where it is made, and check contracts on the
|
|
35
|
+
awaited result. See
|
|
36
|
+
[asynchronous functions](docs/reference/language/async-functions.md).
|
|
37
|
+
|
|
38
|
+
### Other changes
|
|
39
|
+
|
|
40
|
+
- A numeric literal passed to a generic function takes the type its other
|
|
41
|
+
arguments fix: `prelude.insert 1 s` with `s :: Set Int32` needs no
|
|
42
|
+
annotation.
|
|
43
|
+
- Generated schemas no longer revalidate a whole value on each construction,
|
|
44
|
+
match or checked-definition call; values are checked at the adapter
|
|
45
|
+
boundary. Large recursive values test much faster.
|
|
46
|
+
- The list example is now `examples/specs/lists.lawspec`;
|
|
47
|
+
`collections.lawspec` covers the new collections.
|
|
48
|
+
|
|
3
49
|
## 0.16.0
|
|
4
50
|
|
|
5
51
|
### 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.0
|
|
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.0 -- lawspec init --target javascript
|
|
44
|
+
npm install --save-dev lawspec@0.17.0
|
|
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",
|
|
@@ -136,47 +138,49 @@
|
|
|
136
138
|
"wasm/lawspec-wasm.cabal"
|
|
137
139
|
],
|
|
138
140
|
"digests": {
|
|
139
|
-
"dev/Gen/Embed.hs": "
|
|
140
|
-
"lawspec.cabal": "
|
|
141
|
-
"package.yaml": "
|
|
141
|
+
"dev/Gen/Embed.hs": "41cd18500c1a8c9bdb51011ab4c74817f8e04b655aa10d9894aa1b93a3fa858b",
|
|
142
|
+
"lawspec.cabal": "a80664dbccd59b2365eb0c7721e7a809cc513895dacc25df1d654bd33eb5171c",
|
|
143
|
+
"package.yaml": "dbf60bb49b779a36a9764774430f35affe300fccc97e3e6b687a80ee3059237f",
|
|
142
144
|
"runtime/LawSpecCodecs.hs": "1b3f6b40ad49928cf5e9386e06bc2992c9f1271754351b9fa3075e50346ef03b",
|
|
143
|
-
"runtime/
|
|
144
|
-
"runtime/LawSpecDataStrategies.
|
|
145
|
+
"runtime/LawSpecCollectionCodecs.hs": "74caa786801c5142ed040897c7ebb7373abf49ee49e02af53e466646fb624f47",
|
|
146
|
+
"runtime/LawSpecDataStrategies.hs": "9cc5b98476364a6c255dc3eb40c53d65b4a9d4ab0c3961a806b3515a8d5e8f7f",
|
|
147
|
+
"runtime/LawSpecDataStrategies.java": "d06c1eb6c67f3d07ab0c90dc8f8626b48358763b91585c6ea216a47e11886dd0",
|
|
145
148
|
"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": "
|
|
149
|
+
"runtime/LawSpecKotlinCodecs.kt": "416610eb295f2fe0a77dd5a133fc10db081b69a04e1649b33abec60e69f32474",
|
|
150
|
+
"runtime/LawSpecKotlinStrategies.kt": "8ee1edeec1c342f2bc70ca8bdad22ec5aabc38f6f61381fe905b717ffce0688e",
|
|
151
|
+
"runtime/LawSpecRuntime.hs": "59eccad16a99a4118a1f9f51a7556ef133e4b875f2f4f678d394f53cdf03d776",
|
|
152
|
+
"runtime/LawSpecRuntime.java": "8096d2cd35786f4e68991ceef8579337cd3c729f4871c60c261e40a0a4ccc43d",
|
|
153
|
+
"runtime/LawSpecSchema.hs": "c19eedd197fc2359780c1576dd6a1d6e9bcdaf2ed037b5dbb37f3db766356bf9",
|
|
154
|
+
"runtime/LawSpecSchema.java": "67f57d8e91fcf155a443724a5632ef52037a1d67ff12d20f3044cf22d6ca98b2",
|
|
152
155
|
"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": "
|
|
156
|
+
"runtime/lawspec_codecs.go": "e069dd6f4331b9bdcbd50dda8fe5faffca83cb9c7c8ea62ac631d2c9fa951bf4",
|
|
157
|
+
"runtime/lawspec_data_strategies.go": "65ca2a09012c516c17bb66d7381637e71f454740858f648a78b9e536f1c7c600",
|
|
158
|
+
"runtime/lawspec_data_strategies.mjs": "5fe9327a6dda2e759558b77100aec96798f1aed4f517d4bc91f45a543b8d14b9",
|
|
159
|
+
"runtime/lawspec_data_strategies.py": "0d06f0c5b9cdd5f6659f424a328884b670c94b1572ec0fa5d5408a05110d94dd",
|
|
160
|
+
"runtime/lawspec_runtime.go": "870e611874d67f45d70c68e03d2094a37f3a12d8a42d9610d8437b8a8d5af30f",
|
|
161
|
+
"runtime/lawspec_runtime.mjs": "bf51f4ebd2855d26d7958cb2ed4ca6f5e8ec6f8a9e31ee38d8324f6accd40b81",
|
|
162
|
+
"runtime/lawspec_runtime.py": "44f69c30040bd9b7df8f66c18fc3487ca965d6eea4f27f811a5ec403a16f9942",
|
|
163
|
+
"runtime/lawspec_runtime.rs": "49e9a13ab742ac5a192785585548c7ab8f8b8f03cb0046ea03acf4b97c2273ee",
|
|
164
|
+
"runtime/lawspec_schema.go": "7e9361e9693c3885d98500026f3e3ef8e213eb72a489a58fc72669e8a9938103",
|
|
165
|
+
"runtime/lawspec_schema.mjs": "d77abea1a9dcb03e4a6c6eef6509971d8599fac9acdefa9b9e4b89b8d0fc5226",
|
|
166
|
+
"runtime/lawspec_schema.py": "daed20d27168970350ef0b63b9cb2e566bd00598922acb4071d863c076e787ba",
|
|
167
|
+
"runtime/lawspec_strategies.rs": "5e991a45548811fef1728e1e9b9f12f76ee4cc7cb9c3339eab79bc4cf5f54f6b",
|
|
168
|
+
"runtime/rust/Cargo.lock": "06dbc409b525f297e90a6a3255b2af1ad002421873d6e068cbbbf49ea09bf9a4",
|
|
169
|
+
"runtime/rust/Cargo.toml": "efa4b9b3f7b5d8a44652bacc1e49beebb2e53d15d96ef6f8ff9832d589d6125a",
|
|
167
170
|
"src/LawSpec/Api.hs": "b7315b30890e3e38382c7e4d60afdfc6c7c3647f056636c230a91c16047f9944",
|
|
168
|
-
"src/LawSpec/Backend.hs": "
|
|
169
|
-
"src/LawSpec/Capabilities.hs": "
|
|
171
|
+
"src/LawSpec/Backend.hs": "caf45afb73e7455dd801195b8b117ca7e4664ac4babc6ef0732e06faf9e64fcb",
|
|
172
|
+
"src/LawSpec/Capabilities.hs": "ab457f3da440a237ee731d664b94d95a0cc1fa4d8be4d4d0403a61ebcf98e310",
|
|
170
173
|
"src/LawSpec/Code/Doc.hs": "9e3b70f85deb1dcbce385af1d0cd4bea2dfa8a2d806d54745d4bb437406673e5",
|
|
171
174
|
"src/LawSpec/Code/JavaScript.hs": "77bf27dcc210216e4739f68c4709f556f80130ab83b3b9387ac4a2421e790910",
|
|
175
|
+
"src/LawSpec/Collections.hs": "f8cc2978b6690709deb421ee22df37985c80e5b06064f819a193d6b912328ee1",
|
|
172
176
|
"src/LawSpec/Common.hs": "107612a8aaa787488413acf9c1a56622004d3bff251db89b99928343e6070883",
|
|
173
|
-
"src/LawSpec/Compile.hs": "
|
|
174
|
-
"src/LawSpec/Core.hs": "
|
|
177
|
+
"src/LawSpec/Compile.hs": "ec8a077041ec65ae908cf5fe48ed3cd15200f613b5cee7a4331f2f0bd9cb66ca",
|
|
178
|
+
"src/LawSpec/Core.hs": "30f5a20ede2dc810532d7e5c608a7df98b436e4d5e08547b837d5f56c86c270e",
|
|
175
179
|
"src/LawSpec/Core/DefinitionContracts.hs": "b7f60f038b231187ecf898e585ae1a8fb1fc113bb55bad6d1bb2660350fd969e",
|
|
176
180
|
"src/LawSpec/Core/Definitions.hs": "8e0d1d7127f9d4872f2464b4af50b0f286823d5f0f203baf38fb3c316d766140",
|
|
177
|
-
"src/LawSpec/Core/Eval.hs": "
|
|
178
|
-
"src/LawSpec/Core/Evidence.hs": "
|
|
179
|
-
"src/LawSpec/Core/Expression.hs": "
|
|
181
|
+
"src/LawSpec/Core/Eval.hs": "26c518cf3db1f395f69353cb373e1aacf7f1a0ce81d3e17b15878421e9625a8b",
|
|
182
|
+
"src/LawSpec/Core/Evidence.hs": "48442ab98eafaa0f09d56c01493b73b724845347bbd27ae390c64366faec938d",
|
|
183
|
+
"src/LawSpec/Core/Expression.hs": "8b8a55d6fb166012918f0dc83322776505a83a7024a76c49fc568f29137a3702",
|
|
180
184
|
"src/LawSpec/Core/Payload.hs": "da2417fc99354338eab49a688c5f36cecde5ec1aacd8582c895428568b10a376",
|
|
181
185
|
"src/LawSpec/Core/PayloadPlan.hs": "f2a7d2dc58c6a0f79707bdc24773bd3aad3a3b8eea2735a8284b2a9f3a4af4a8",
|
|
182
186
|
"src/LawSpec/Core/RefinementProof.hs": "c19fc03e68488357a59897ec38ce3d2efd320c35b405b632af17425d6a18447a",
|
|
@@ -184,92 +188,92 @@
|
|
|
184
188
|
"src/LawSpec/Core/Semantics.hs": "cdb8256e523f7808fa50fe7d80d709217a28de4c81c5ff5be8382f94900f3779",
|
|
185
189
|
"src/LawSpec/Core/Total.hs": "308684d7ff78a5e4dc75aef30c4df17610a2cb107d48ddb75d14d8573b178e5b",
|
|
186
190
|
"src/LawSpec/Core/Totality.hs": "5e76100466cf4a157b9eda36738806af836a5bda949f5d568d7bf5155fa8858a",
|
|
187
|
-
"src/LawSpec/Core/Types.hs": "
|
|
191
|
+
"src/LawSpec/Core/Types.hs": "f4689fb690148be0171403ba2bf0e29f841cee3381bf2a8ad1daf45841140097",
|
|
188
192
|
"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": "
|
|
193
|
+
"src/LawSpec/Core/Value.hs": "1f4eddd1e4c642f91478fa7009bc4edbd9f6f4da115c11e03021f4e4e9f0b275",
|
|
194
|
+
"src/LawSpec/CoreEmit.hs": "e006dd23a77fea0918b5a5a9dd1aaba5f56c55e74d8f717f91266b94463f7d80",
|
|
195
|
+
"src/LawSpec/CoreNativeScalarEmit.hs": "389f1940596512d91ba813c2f20ed66fe7c972cfc2e44d76e4e8a61d5f3c52b7",
|
|
196
|
+
"src/LawSpec/CoreScalarEmit.hs": "4b45ec70b9074d54c9e023d482d5926ec3f679c167eb4f68f6de9679dfb98f8e",
|
|
193
197
|
"src/LawSpec/Data.hs": "f659f4e86f1009c4806334a45686970dde2efa2641585f997a7beba01d0e6f2d",
|
|
194
198
|
"src/LawSpec/DataNames.hs": "2eeb0d215131981a2271725a50c21dce44c7146a167025eb239a83922fdecaf6",
|
|
195
|
-
"src/LawSpec/DefinitionTotality.hs": "
|
|
199
|
+
"src/LawSpec/DefinitionTotality.hs": "adf00236e0e1b1cad4299793ced5f9047dbc2321d3c2f9ba040bac30d1a87c73",
|
|
196
200
|
"src/LawSpec/Discharge.hs": "bd1acbddecf1f060aaaad1a6796825321c56b434d556e9873eb6c9d99459fdb7",
|
|
197
201
|
"src/LawSpec/Domain.hs": "222d15f0012ae630802238a6d7e1ee78d1e718b599f5ebb5a1ddc4e8d29d68c3",
|
|
198
202
|
"src/LawSpec/DomainModel.hs": "835e6e31c9565bd624c1139ead71ad65c1065ee660457ae365522f7ed78f7939",
|
|
199
|
-
"src/LawSpec/Elaboration.hs": "
|
|
203
|
+
"src/LawSpec/Elaboration.hs": "aade19ada1b9b944d1d5864b1ada61f89a57a675d7e8de9e2f3bc6b6f6d84b00",
|
|
200
204
|
"src/LawSpec/Emit.hs": "9f34f5765915a2a12a66a6dca647ddaef9289372956802c6d99cf0cfec447c7a",
|
|
201
205
|
"src/LawSpec/Eval.hs": "b87a786ed7a512c60e00a037a1a36738933518aafa255babaa8b1b42dbb8ff6d",
|
|
202
206
|
"src/LawSpec/Flow.hs": "830b9d59b94f26a05687bd5baed06b4ecbf1f47c6a634766810d3dd2a44647cd",
|
|
203
207
|
"src/LawSpec/Frontend.hs": "5f2bb4f3580b8fca6d899a0b40000da653fb7e76f11f8c8df271eb023ad5b278",
|
|
204
|
-
"src/LawSpec/GoData.hs": "
|
|
205
|
-
"src/LawSpec/GoDefinitions.hs": "
|
|
206
|
-
"src/LawSpec/GoExpr.hs": "
|
|
208
|
+
"src/LawSpec/GoData.hs": "ffd2f91688e4efdbd65033b88ad55032278f9b29d8027f6dc9e4b2c3eb9bfbc0",
|
|
209
|
+
"src/LawSpec/GoDefinitions.hs": "907fb5ba9935391fa640c0cf6d037db78d270467a8b93e1190a9d511f03561ff",
|
|
210
|
+
"src/LawSpec/GoExpr.hs": "67ef004e97074976e0fd137dfef8d417efe8de3f7d5c3c08293874d30d89e9d0",
|
|
207
211
|
"src/LawSpec/GoNativeBinding.hs": "1ad8ea4cec6187c7e6005651c0edeec69e196eb329fb958c833da7751225aa1b",
|
|
208
|
-
"src/LawSpec/GoProperties.hs": "
|
|
212
|
+
"src/LawSpec/GoProperties.hs": "a6118510ae472de8cbeb0f1dfb025f23a84123bccc5a53af20ad39470851e639",
|
|
209
213
|
"src/LawSpec/GoTestHelpers.hs": "dee55ee8505370e932773b8c685f4a1f380129e6f43f8806bf1e82efb99451b1",
|
|
210
214
|
"src/LawSpec/GoTypeRefs.hs": "7f239f5ac3ac8bd21c8f76c328049f7715d8562ee1382befa0a58abd4f15f726",
|
|
211
|
-
"src/LawSpec/HaskellData.hs": "
|
|
212
|
-
"src/LawSpec/HaskellDefinitions.hs": "
|
|
213
|
-
"src/LawSpec/HaskellExpr.hs": "
|
|
215
|
+
"src/LawSpec/HaskellData.hs": "8ca1f1a353972a28b3d044c3763243cd8a2abf3e2cdb3b15b6112d8a7edf9da2",
|
|
216
|
+
"src/LawSpec/HaskellDefinitions.hs": "9481901b9f1753dbfe90dcc859275eaab474acdb2f41035cd14e9d03cce45440",
|
|
217
|
+
"src/LawSpec/HaskellExpr.hs": "f7ef064ac6700c027de4bd71bddeb3236853232cf7a39bed61de16153539b401",
|
|
214
218
|
"src/LawSpec/HaskellNativeBinding.hs": "9f98aa0c8659b572bd6486a0e29c4692bc6432db8639fa74a09bbf1b771bbfa6",
|
|
215
|
-
"src/LawSpec/HaskellProperties.hs": "
|
|
219
|
+
"src/LawSpec/HaskellProperties.hs": "3f99a4083b602e3a197446614f66f127384b2babd6039c5d3189a81c75329db4",
|
|
216
220
|
"src/LawSpec/HaskellTestHelpers.hs": "51e59b2abc9e85455e3c8e2c6baadb27e5d319081cb730d2ce56be5dc8053897",
|
|
217
221
|
"src/LawSpec/HaskellTypeRefs.hs": "2225b2a5e2ab3662e7202d23b24f4d6db48353b35ae28df8acd2b92fd2b97574",
|
|
218
|
-
"src/LawSpec/Imports.hs": "
|
|
222
|
+
"src/LawSpec/Imports.hs": "1182894623b69e777531706c013b5ecd9995c51dd8c8b969c1807a5a103bf2da",
|
|
219
223
|
"src/LawSpec/IndexTerm.hs": "65e7942306f08683ec9f284f76b10ad271f8a909b1ec721da04f6275c9a1d20e",
|
|
220
224
|
"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": "
|
|
225
|
+
"src/LawSpec/Inference.hs": "8d3a8853bd691329d6d1cf0cdde9e4e8f8c895f5be944f2e77e9df348d1aa0eb",
|
|
226
|
+
"src/LawSpec/JavaData.hs": "8afc712aed51240921cd6830b5d21ab029f71cc5cb0de56ca522eadd94ccb600",
|
|
227
|
+
"src/LawSpec/JavaDefinitions.hs": "ba771b59878d8780613d1d40094597e8dca0478ccde11188a39df77667a01dab",
|
|
228
|
+
"src/LawSpec/JavaExpr.hs": "fb1d3e64f3288e557720dead7738eb4f2a59d4563e5be4a742e1582829f19d3e",
|
|
225
229
|
"src/LawSpec/JavaNativeBinding.hs": "9eb52b3be19badda078069bb3d6813d72cad4f0a9bfa708f7404e44201d3c352",
|
|
226
|
-
"src/LawSpec/JavaProperties.hs": "
|
|
230
|
+
"src/LawSpec/JavaProperties.hs": "7438793af96d9e9e2072670c4bc20f56729c85e054d598b5ad4e991bfdf094a1",
|
|
227
231
|
"src/LawSpec/JavaTestHelpers.hs": "e6f4b9bbb7e5f07ece6ab1845e12aa661e62e8b926680b11454223fc3ec1523d",
|
|
228
|
-
"src/LawSpec/KotlinData.hs": "
|
|
232
|
+
"src/LawSpec/KotlinData.hs": "ca3bad4dca9fcd604cd39ec713ef8ed38966aaf24b1d6b33d88d405bfc80641d",
|
|
229
233
|
"src/LawSpec/KotlinDefinitions.hs": "97d7d407d4bbdb4ce16035d607dbbcb8e3d6f5db513f2123a2c269e3dc6d2b38",
|
|
230
234
|
"src/LawSpec/KotlinExpr.hs": "20312f0774f1d0832a21a19b93c8103e2791ecd32a827d8e9c4f2b4830a996a0",
|
|
231
235
|
"src/LawSpec/KotlinNativeBinding.hs": "1aec7854758f07a4d2288de13931fbb88ef32220f85d3c84fe8233ad67b6d095",
|
|
232
|
-
"src/LawSpec/KotlinProperties.hs": "
|
|
236
|
+
"src/LawSpec/KotlinProperties.hs": "5c7289c97cc915cbc3432eb4b08a2fefbe786af4d6591af4b59923aa9d6a2075",
|
|
233
237
|
"src/LawSpec/KotlinTestHelpers.hs": "74810d65faafc6ed4d64b1fb0596cda4186e586b7144a7441641b798795bc324",
|
|
234
|
-
"src/LawSpec/Model.hs": "
|
|
238
|
+
"src/LawSpec/Model.hs": "72fae874b4a5aa98057254fc1b508df3f71ec8587740bc7c18ea29490526137b",
|
|
235
239
|
"src/LawSpec/NativeBinding.hs": "33959b0fd432ad4150f3b685f6438e284b801c2a59d9ef3132486a1cc7c8925a",
|
|
236
|
-
"src/LawSpec/NativeRequest.hs": "
|
|
240
|
+
"src/LawSpec/NativeRequest.hs": "f8200c36725859ea32374655951f7a45e2b3342b159f9f6c88b5f9a2a6331897",
|
|
237
241
|
"src/LawSpec/Packages.hs": "161fc68a9959a80762ca4ece405240351e3180ea4dbb2bf148eaca6562fb7c30",
|
|
238
|
-
"src/LawSpec/Parser.hs": "
|
|
242
|
+
"src/LawSpec/Parser.hs": "953e907c51e12724085a6ce0504c767a8d622acf7ad4479913ed2cb86017251e",
|
|
239
243
|
"src/LawSpec/PortableGenerator.hs": "69d457e39f539c77fc7a4c08205e75352bbecd9dfdff031a283a39bf44b22d49",
|
|
240
|
-
"src/LawSpec/PortableTestHelpers.hs": "
|
|
244
|
+
"src/LawSpec/PortableTestHelpers.hs": "8d98184c92a34b431f2a820cef3ea735b0cec3a52504f519b3bb06cb5174017c",
|
|
241
245
|
"src/LawSpec/Prelude.hs": "b1e155c12f58e7c346551a0c65c5d5af76d045b3f1625977ca2a5d1c97cb8c46",
|
|
242
|
-
"src/LawSpec/Public.hs": "
|
|
243
|
-
"src/LawSpec/PythonData.hs": "
|
|
244
|
-
"src/LawSpec/PythonDefinitions.hs": "
|
|
246
|
+
"src/LawSpec/Public.hs": "7010357e250607a9f94d1ab8dc34fad4014fb7d9f15ba0d7c2fc94d0f48fcac4",
|
|
247
|
+
"src/LawSpec/PythonData.hs": "bb6e947829aa7611f39fb74152e8ef013c192be717a3573f12d249973ca65e5d",
|
|
248
|
+
"src/LawSpec/PythonDefinitions.hs": "387a3f7678a7968249805365602206ebc0bb8d5b56924534d35294a1a98b0e5f",
|
|
245
249
|
"src/LawSpec/PythonExpr.hs": "23d7d24b5fb4efff9cb63d38c02a93d95744ec79b4565daf1412088fc7c4ba59",
|
|
246
250
|
"src/LawSpec/PythonNativeBinding.hs": "4e35ff8781062d0f614e45ea45f98038c8d609ab78bd671cb0a239eaa9db1690",
|
|
247
|
-
"src/LawSpec/PythonTypes.hs": "
|
|
251
|
+
"src/LawSpec/PythonTypes.hs": "d465eef5fecef5d011fa422655d51cd1123800a39cfaf042545d41f2557bd98c",
|
|
248
252
|
"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": "
|
|
253
|
+
"src/LawSpec/RuntimeSources.hs": "b984cd8635be4109ea79fff5becb9accb1379f5322aaf6c50938264f01ba47b6",
|
|
254
|
+
"src/LawSpec/RustData.hs": "b8bb35f2cc5835c811e01e8bbbe172f483ab2620e1e8e331cdfaf6342c23e7f1",
|
|
255
|
+
"src/LawSpec/RustDefinitions.hs": "8211ad8c4db088ae658918b5172a666303aaf1bfe3f29bdd0b520a77015b2892",
|
|
256
|
+
"src/LawSpec/RustEmit.hs": "a57aaef4f6980a4d00b6fee1caf099b5ee317f1f8f6cfc9c480f68a431d39942",
|
|
253
257
|
"src/LawSpec/RustExpr.hs": "04b2ef81417b811c7b98a98acdadab4e588ca8757964a63ba8dc5936c36479e6",
|
|
254
258
|
"src/LawSpec/RustNativeBinding.hs": "d50d1fb10591ee86129ae49b38a343148c084479e450eef3b320e1efdd55245d",
|
|
255
259
|
"src/LawSpec/RustNativeGenerators.hs": "a3b1484d9ff0008e4f961aa81d0aa51da57ec0cd7909124e80c98d56aacc8ce9",
|
|
256
|
-
"src/LawSpec/Scaffold.hs": "
|
|
260
|
+
"src/LawSpec/Scaffold.hs": "217328445923b9e339428dd542ce9b910c26ed132c31d1ef083de73763b749f9",
|
|
257
261
|
"src/LawSpec/Scalar.hs": "f7eddc660dbc08d315d85291e446ed5c34670e2321f9268ba852ebf65e206141",
|
|
258
262
|
"src/LawSpec/SpecializeDefinitions.hs": "2bdd6d9b191941d869ef524659e02fed551499aaa2ea98c99323da03af113012",
|
|
259
|
-
"src/LawSpec/Testing.hs": "
|
|
260
|
-
"src/LawSpec/WebData.hs": "
|
|
261
|
-
"src/LawSpec/WebDefinitions.hs": "
|
|
263
|
+
"src/LawSpec/Testing.hs": "fb4299ad7e68d84e32991b5397c39f2fd06eb1417a0bf8b14fe2d85cfa9c26db",
|
|
264
|
+
"src/LawSpec/WebData.hs": "bbcd7d734ce3941d83cc455a9a2147b642f6111ebb34db9ef99dcb7a58b8c4ae",
|
|
265
|
+
"src/LawSpec/WebDefinitions.hs": "579309c76b9303a3c9e456e1252f2d0881795210aa0b09104a00efdfe10e3e13",
|
|
262
266
|
"src/LawSpec/WebExpr.hs": "0389dcd5cf7479dd23ef034b1012de6ebd70bf1dc9e3d90981dfb0ba2702596f",
|
|
263
267
|
"src/LawSpec/WebNativeBinding.hs": "f536c1b1454bc83f5a9e8c61a608390b9a6fa91537f34d3c245b90ee6e275b7d",
|
|
264
|
-
"src/LawSpec/WebTypes.hs": "
|
|
268
|
+
"src/LawSpec/WebTypes.hs": "1d43194e4dafbdcbed6e607414a875e9030028f03579f17d189c14a6a9bd5e53",
|
|
265
269
|
"src/LawSpec/Witness.hs": "9ae944c9307df964bc853205269c1e4cb69cc076070bb878fc957f4bdb02de85",
|
|
266
270
|
"stack.yaml": "20ccf4d599e355e60b7aa4f814a7cd4299fe2048616cc2e6dbdc22a7bd8cec73",
|
|
267
271
|
"stack.yaml.lock": "ae222b9c81af920c56e50fa4596fa57786e7fa5a7b461390362b2b2ff63818c7",
|
|
268
272
|
"wasm/app/Exports.hs": "4ecbdac8faa2449e6fc61b93c82e6278fa14374154f29b4dacf0eef433f06a47",
|
|
269
273
|
"wasm/cabal.project": "021e560afdc5eb4cb7169e7119ecb8f92c9ee170245af909c94b612941bff5cc",
|
|
270
274
|
"wasm/cabal.project.freeze": "733dbed3d2ecccb26e874fd58f136296dad772184deb1658c196b5d54a0814dc",
|
|
271
|
-
"wasm/lawspec-wasm.cabal": "
|
|
272
|
-
"npm/core.wasm": "
|
|
275
|
+
"wasm/lawspec-wasm.cabal": "c4be9cf8ffe6ed3f54000311845595ea9a9094dbbfc1dd735be90d9ba23e08ab",
|
|
276
|
+
"npm/core.wasm": "369eb593bfdf2824102cec5f9097ee9d7958be71394d432e5b09aae408db333b",
|
|
273
277
|
"npm/core_jsffi.js": "88d136efe92f7cff5758c8fec8d9b6bbc9707fe37741cebeeb415fe34ce3d72b",
|
|
274
278
|
"npm/api.mjs": "19e1624f91258c1397f3212faf65b407c62671b0fc5b118520e6a91f7ad7c6ba",
|
|
275
279
|
"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
|
},
|