lawspec 0.17.5 → 0.18.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 CHANGED
@@ -1,5 +1,78 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Railway combinators
6
+
7
+ - `>>=`, `<$>`, `<!>`, `<|>`, `??`, `>=>`, `|>` and `<*>`, and the prelude
8
+ names `bind`, `then`, `map`, `mapError`, `orElse`, `fallback`, `fromEither`,
9
+ `andThen`, `pipe`, `both`, `ensure`, `isLeft` and `isRight`, sequence, map
10
+ and recover `Either` values in laws and checked definitions on every target.
11
+ See [expressions](docs/reference/language/expressions-and-arithmetic.md).
12
+ - `Pair` joins the built-in collections unit, and `prelude.select` chooses
13
+ between two values.
14
+
15
+ ### Generated workflows
16
+
17
+ - LawSpec now generates each `workflow` on every target from its stages:
18
+ steps, `then`, `map`, `mapError`, `tap`, `ensure`, `orElse`, `fallback`, and
19
+ `all` groups whose results `combine` joins. With `accumulate`, an `all`
20
+ group reports every failing step's error. See
21
+ [workflows](docs/reference/language/workflows.md).
22
+ - Steps may fail with different error types. A declared error type takes them
23
+ through `mapError`; with `Either _ T`, LawSpec generates an error type named
24
+ after the workflow, with a constructor per failing step
25
+ (`PlaceOrderValidateOrderFailed`).
26
+ - Generated laws check that each workflow composes its stages, succeeds when
27
+ every stage does, stops when a step fails, and recovers with each handler.
28
+ - **Migration:** hand-written workflow adapters are no longer called. Remove
29
+ them, and move any behaviour they had into the steps.
30
+
31
+ ### Policies
32
+
33
+ - A step can run under `retry` (immediate, fixed, linear, exponential,
34
+ fibonacci or custom, with optional jitter and a `when` predicate),
35
+ `timeout`, `rateLimit` (token bucket, leaky bucket, fixed or sliding
36
+ window; wait or reject), `circuitBreaker`, `bulkhead`, `cache`,
37
+ `compensate` and `hedge`. A policy failure becomes a constructor of a
38
+ generated error type, or the value a declared error type names with `else`.
39
+ - Workflows run under a workflow runtime: a real or virtual clock, a SplitMix64
40
+ random source identical on every target, a trace, and the state of
41
+ limiters, breakers, bulkheads and caches. Callers create one to give a
42
+ workflow its own state or a virtual clock; otherwise a shared runtime is used.
43
+ - The rate limits, breaker and bulkhead are written once, as checked
44
+ definitions of a built-in unit, `lawspec.resilience`, so they behave the same
45
+ on every target. A new resilience acceptance suite checks each target's
46
+ runtime against them.
47
+ - Generated tests run workflows on a virtual clock with stateful policies,
48
+ timeouts and hedges off; retries still apply.
49
+
50
+ ### Durations
51
+
52
+ - `Duration` is a whole number of microseconds, exact on every target, with
53
+ literals (`250ms`, `2s`, `5min`), arithmetic, comparisons and native types
54
+ (`timedelta`, `time.Duration`, `java.time.Duration`,
55
+ `kotlin.time.Duration`, `std::time::Duration`). See
56
+ [durations](docs/reference/language/durations.md).
57
+ - The totality audit proves more: products and quotients are atoms, quotients
58
+ are bounded, calls satisfy their definitions' postconditions, and unwrapped
59
+ wrapper values satisfy their constraints.
60
+
61
+ ### Other changes
62
+
63
+ - A definition or adapter named with a target keyword is emitted with a
64
+ leading underscore on that target (`class` is `_class` in Python); such names
65
+ were rejected or broke the build before.
66
+ - On JavaScript and TypeScript, a checked definition that calls an `async`
67
+ adapter, directly or through another definition, is itself `async`.
68
+ - Kotlin workflows can call `suspend` adapters. The Kotlin scaffold depends on
69
+ `kotlinx-coroutines-core`, and `lawspec doctor` reports it missing.
70
+ - Python: a synchronous definition called from inside a running event loop
71
+ (from an `async` adapter) awaits its asynchronous steps on a thread of its
72
+ own instead of failing.
73
+ - Python property tests have no per-example deadline, since adapters may do
74
+ real work.
75
+
3
76
  ## 0.17.5
4
77
 
5
78
  ### `lawspec test` confirms that each law's tests ran
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.17.5
33
+ npm install --save-dev lawspec@0.18.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.17.5 -- lawspec init --target javascript
44
- npm install --save-dev lawspec@0.17.5
43
+ npm exec --package=lawspec@0.18.0 -- lawspec init --target javascript
44
+ npm install --save-dev lawspec@0.18.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
@@ -17,7 +17,7 @@ import {
17
17
  atomicWrite,
18
18
  safePath,
19
19
  } from "../files.mjs";
20
- const VERSION = "0.17.5";
20
+ const VERSION = "0.18.0";
21
21
  const args = process.argv.slice(2);
22
22
  const verb = args.shift();
23
23
  const options = {};
package/build.json CHANGED
@@ -46,9 +46,11 @@
46
46
  "src/LawSpec/Core/Expression.hs",
47
47
  "src/LawSpec/Core/Payload.hs",
48
48
  "src/LawSpec/Core/PayloadPlan.hs",
49
+ "src/LawSpec/Core/Policy.hs",
49
50
  "src/LawSpec/Core/RefinementProof.hs",
50
51
  "src/LawSpec/Core/Schema.hs",
51
52
  "src/LawSpec/Core/Semantics.hs",
53
+ "src/LawSpec/Core/Stages.hs",
52
54
  "src/LawSpec/Core/Total.hs",
53
55
  "src/LawSpec/Core/Totality.hs",
54
56
  "src/LawSpec/Core/Types.hs",
@@ -117,7 +119,9 @@
117
119
  "src/LawSpec/PythonExpr.hs",
118
120
  "src/LawSpec/PythonNativeBinding.hs",
119
121
  "src/LawSpec/PythonTypes.hs",
122
+ "src/LawSpec/Railway.hs",
120
123
  "src/LawSpec/Refinement.hs",
124
+ "src/LawSpec/Resilience.hs",
121
125
  "src/LawSpec/RuntimeSources.hs",
122
126
  "src/LawSpec/RustData.hs",
123
127
  "src/LawSpec/RustDefinitions.hs",
@@ -128,8 +132,10 @@
128
132
  "src/LawSpec/Scaffold.hs",
129
133
  "src/LawSpec/Scalar.hs",
130
134
  "src/LawSpec/SpecializeDefinitions.hs",
135
+ "src/LawSpec/TargetNames.hs",
131
136
  "src/LawSpec/TestManifest.hs",
132
137
  "src/LawSpec/Testing.hs",
138
+ "src/LawSpec/Time.hs",
133
139
  "src/LawSpec/WebData.hs",
134
140
  "src/LawSpec/WebDefinitions.hs",
135
141
  "src/LawSpec/WebExpr.hs",
@@ -145,137 +151,143 @@
145
151
  ],
146
152
  "digests": {
147
153
  "dev/Gen/Embed.hs": "41cd18500c1a8c9bdb51011ab4c74817f8e04b655aa10d9894aa1b93a3fa858b",
148
- "lawspec.cabal": "7f6395dbb39d2baeff82eace1a6ef176f6b825297b772d21e6d3fe9b88db0ec2",
149
- "package.yaml": "9d6cee849b08b1df8161d36390876dc2dc6aa33c34844588d6a3cd9fb0e81699",
154
+ "lawspec.cabal": "a5b307f47140711064647dda585c4f882af8072c9118d9c637e4c52bdac6032f",
155
+ "package.yaml": "7e5212a8889ae07c4200ad953e4b40b5af7b0497fef565e5469e93526f3727b9",
150
156
  "runtime/LawSpecCodecs.hs": "1b3f6b40ad49928cf5e9386e06bc2992c9f1271754351b9fa3075e50346ef03b",
151
157
  "runtime/LawSpecCollectionCodecs.hs": "74caa786801c5142ed040897c7ebb7373abf49ee49e02af53e466646fb624f47",
152
158
  "runtime/LawSpecDataStrategies.hs": "9cc5b98476364a6c255dc3eb40c53d65b4a9d4ab0c3961a806b3515a8d5e8f7f",
153
159
  "runtime/LawSpecDataStrategies.java": "d06c1eb6c67f3d07ab0c90dc8f8626b48358763b91585c6ea216a47e11886dd0",
154
160
  "runtime/LawSpecKotlin.kt": "0cf3b7de0406155225ccca33ee3dfdf8f0456c47d577f6be8f1265c13df838cb",
155
- "runtime/LawSpecKotlinCodecs.kt": "416610eb295f2fe0a77dd5a133fc10db081b69a04e1649b33abec60e69f32474",
161
+ "runtime/LawSpecKotlinCodecs.kt": "811accd1cac055d46f7ae0a2aff03602389fbbaaa2eaf778a9dcdd6899b12466",
156
162
  "runtime/LawSpecKotlinStrategies.kt": "8ee1edeec1c342f2bc70ca8bdad22ec5aabc38f6f61381fe905b717ffce0688e",
157
- "runtime/LawSpecRuntime.hs": "59eccad16a99a4118a1f9f51a7556ef133e4b875f2f4f678d394f53cdf03d776",
158
- "runtime/LawSpecRuntime.java": "8096d2cd35786f4e68991ceef8579337cd3c729f4871c60c261e40a0a4ccc43d",
163
+ "runtime/LawSpecRuntime.hs": "63b6c7d12271bec263c6095ebc2fe9318799eff4235f3b877f63a967a4b81352",
164
+ "runtime/LawSpecRuntime.java": "c7763b4f2a6060b696f89ff0a932ccc68d5d9af3cbfdc258614c7b90aec4ff8a",
159
165
  "runtime/LawSpecSchema.hs": "c19eedd197fc2359780c1576dd6a1d6e9bcdaf2ed037b5dbb37f3db766356bf9",
160
- "runtime/LawSpecSchema.java": "67f57d8e91fcf155a443724a5632ef52037a1d67ff12d20f3044cf22d6ca98b2",
166
+ "runtime/LawSpecSchema.java": "bdf02d151db8635956d5d1266ba4434e507aee573eb8659112df010980a8d854",
161
167
  "runtime/LawSpecStrategies.kt": "569f7775c0ac44765d05567cbf62d026558ac193c080ca71681ec6ee49c21794",
162
- "runtime/lawspec_codecs.go": "e069dd6f4331b9bdcbd50dda8fe5faffca83cb9c7c8ea62ac631d2c9fa951bf4",
168
+ "runtime/lawspec_codecs.go": "57dadec7eb3e9912178b3d6f2e507a42f03f4e81807ffd30385dba446f6ef4dd",
163
169
  "runtime/lawspec_data_strategies.go": "65ca2a09012c516c17bb66d7381637e71f454740858f648a78b9e536f1c7c600",
164
170
  "runtime/lawspec_data_strategies.mjs": "5fe9327a6dda2e759558b77100aec96798f1aed4f517d4bc91f45a543b8d14b9",
165
171
  "runtime/lawspec_data_strategies.py": "0d06f0c5b9cdd5f6659f424a328884b670c94b1572ec0fa5d5408a05110d94dd",
166
- "runtime/lawspec_runtime.go": "870e611874d67f45d70c68e03d2094a37f3a12d8a42d9610d8437b8a8d5af30f",
167
- "runtime/lawspec_runtime.mjs": "bf51f4ebd2855d26d7958cb2ed4ca6f5e8ec6f8a9e31ee38d8324f6accd40b81",
168
- "runtime/lawspec_runtime.py": "44f69c30040bd9b7df8f66c18fc3487ca965d6eea4f27f811a5ec403a16f9942",
169
- "runtime/lawspec_runtime.rs": "49e9a13ab742ac5a192785585548c7ab8f8b8f03cb0046ea03acf4b97c2273ee",
172
+ "runtime/lawspec_runtime.go": "36f73eedd4ca35e6b7ebb93fd63ac356e8e04366c63c80b42cf72112ec8b8ba8",
173
+ "runtime/lawspec_runtime.mjs": "576389ebdc770bddb4092bb9229a71ce54e37ba8da90ffde8de15305004c0ec8",
174
+ "runtime/lawspec_runtime.py": "93c8b0bf87d9e6af26bb33e4c1d8611927df295e9cab9d11f73872d0f35ccbf6",
175
+ "runtime/lawspec_runtime.rs": "1e9f898325dda99e44f07e7d422e7b234ebae73d7845d98391f8e3d6851c6f0e",
170
176
  "runtime/lawspec_schema.go": "7e9361e9693c3885d98500026f3e3ef8e213eb72a489a58fc72669e8a9938103",
171
177
  "runtime/lawspec_schema.mjs": "d77abea1a9dcb03e4a6c6eef6509971d8599fac9acdefa9b9e4b89b8d0fc5226",
172
- "runtime/lawspec_schema.py": "daed20d27168970350ef0b63b9cb2e566bd00598922acb4071d863c076e787ba",
173
- "runtime/lawspec_strategies.rs": "5e991a45548811fef1728e1e9b9f12f76ee4cc7cb9c3339eab79bc4cf5f54f6b",
174
- "runtime/rust/Cargo.lock": "6a04cf0315ad2920129cdc61350098d8edc69d8ca17c9e8829c799560ec46db9",
175
- "runtime/rust/Cargo.toml": "d9dc489e41368122f5d13edd26383a6c27f33064d701c816fdc7c94878e7d8c5",
178
+ "runtime/lawspec_schema.py": "dd29fd2624c204442bfd3ed8a420a853413aa520c5d99f4e5028db7ce21e34c8",
179
+ "runtime/lawspec_strategies.rs": "6c21050184ac20b2ad38e99f47b78fb013f1916389e85e522dd73209133af990",
180
+ "runtime/rust/Cargo.lock": "f7200d8d23c2325ba49315e5f03b58957c0a1df6ef9fea3542aa0bd95ed605ee",
181
+ "runtime/rust/Cargo.toml": "e5c2240c00392995e668ce50c26bd1e96cd57719b3769d09bab077519a5cd198",
176
182
  "src/LawSpec/Api.hs": "c0cb09ea2754f79138697e6ee6b4817a43d8343cb410380389d6b321c2feb07b",
177
- "src/LawSpec/Backend.hs": "caf45afb73e7455dd801195b8b117ca7e4664ac4babc6ef0732e06faf9e64fcb",
183
+ "src/LawSpec/Backend.hs": "709581d869bbc3c3103d72b8d4b4d506b96eceefee03add45ca36acd5cedf41c",
178
184
  "src/LawSpec/Capabilities.hs": "ab457f3da440a237ee731d664b94d95a0cc1fa4d8be4d4d0403a61ebcf98e310",
179
185
  "src/LawSpec/Code/Doc.hs": "9e3b70f85deb1dcbce385af1d0cd4bea2dfa8a2d806d54745d4bb437406673e5",
180
186
  "src/LawSpec/Code/JavaScript.hs": "77bf27dcc210216e4739f68c4709f556f80130ab83b3b9387ac4a2421e790910",
181
- "src/LawSpec/Collections.hs": "f8cc2978b6690709deb421ee22df37985c80e5b06064f819a193d6b912328ee1",
187
+ "src/LawSpec/Collections.hs": "0635f3164c8d234956b7d47c7da3d2ab7a857e3d7eca55873777cf4492356f95",
182
188
  "src/LawSpec/Common.hs": "107612a8aaa787488413acf9c1a56622004d3bff251db89b99928343e6070883",
183
- "src/LawSpec/Compile.hs": "d46086c7fded4fa6f4edcf0f66723c3df44d5093a05511290d4f5e8d394741ed",
184
- "src/LawSpec/Core.hs": "ebf780f4552bc3ad304823b7eb7c2560b925cea3f2b2f9322467abae14c2947d",
189
+ "src/LawSpec/Compile.hs": "efca518b2f0a7dff48927dedc3d6752e10228520d1cae4567aabc2bfac3d94a1",
190
+ "src/LawSpec/Core.hs": "3584b20ad29ba9a939c6ba8967757f4cb49078e325bec7acdf4b2e00cdde3bb2",
185
191
  "src/LawSpec/Core/DefinitionContracts.hs": "b7f60f038b231187ecf898e585ae1a8fb1fc113bb55bad6d1bb2660350fd969e",
186
- "src/LawSpec/Core/Definitions.hs": "8e0d1d7127f9d4872f2464b4af50b0f286823d5f0f203baf38fb3c316d766140",
187
- "src/LawSpec/Core/Eval.hs": "26c518cf3db1f395f69353cb373e1aacf7f1a0ce81d3e17b15878421e9625a8b",
192
+ "src/LawSpec/Core/Definitions.hs": "a57e30f6864a6bae7e60cd08ef968b1adc9bbd1c86d4b20c405276eccd604f8d",
193
+ "src/LawSpec/Core/Eval.hs": "7c55598054f76e5f3c332a53df46bc2090a4914e8e1460671896f50db0102a9d",
188
194
  "src/LawSpec/Core/Evidence.hs": "48442ab98eafaa0f09d56c01493b73b724845347bbd27ae390c64366faec938d",
189
- "src/LawSpec/Core/Expression.hs": "8b8a55d6fb166012918f0dc83322776505a83a7024a76c49fc568f29137a3702",
195
+ "src/LawSpec/Core/Expression.hs": "850ff201b56553021404ed783e037f9a27a7d70658c62f5e22e89868bb06044a",
190
196
  "src/LawSpec/Core/Payload.hs": "da2417fc99354338eab49a688c5f36cecde5ec1aacd8582c895428568b10a376",
191
197
  "src/LawSpec/Core/PayloadPlan.hs": "f2a7d2dc58c6a0f79707bdc24773bd3aad3a3b8eea2735a8284b2a9f3a4af4a8",
198
+ "src/LawSpec/Core/Policy.hs": "c0fdb7babe904bafa0fe97c2089f63ae393c3e8845a6d3110e12d8531e0656f0",
192
199
  "src/LawSpec/Core/RefinementProof.hs": "c19fc03e68488357a59897ec38ce3d2efd320c35b405b632af17425d6a18447a",
193
200
  "src/LawSpec/Core/Schema.hs": "ce06bd96b63d11f80be518e626b33526668ae1e2f3f7fc626bb1048e296efc21",
194
201
  "src/LawSpec/Core/Semantics.hs": "cdb8256e523f7808fa50fe7d80d709217a28de4c81c5ff5be8382f94900f3779",
195
- "src/LawSpec/Core/Total.hs": "308684d7ff78a5e4dc75aef30c4df17610a2cb107d48ddb75d14d8573b178e5b",
196
- "src/LawSpec/Core/Totality.hs": "5e76100466cf4a157b9eda36738806af836a5bda949f5d568d7bf5155fa8858a",
202
+ "src/LawSpec/Core/Stages.hs": "b88b974e3510ca797bd4ad8a22c47d63cce28245fc4775999d666e8f2d8dac56",
203
+ "src/LawSpec/Core/Total.hs": "d706a145c3663b6bd3f0ecf390fee1fe4847564ec4f9ce70fa7583ead04a933a",
204
+ "src/LawSpec/Core/Totality.hs": "a9460bc11a91be583274bf4e87bbc85630a544736c4d532a61cf9038f1a3d42d",
197
205
  "src/LawSpec/Core/Types.hs": "04d9c093fcc0d84e2864c8a3b69d5fe318a92c60b32844048198f1b12fe1b6fb",
198
206
  "src/LawSpec/Core/Validate.hs": "74c2a51eb913f8414268064f22d2d5d97ebfb0e4797e146b229076c29ac38726",
199
207
  "src/LawSpec/Core/Value.hs": "52fedabbc07c8c65acc5be1efc7b4860bee47b58931ef76d26fcbfc8a280bf41",
200
- "src/LawSpec/CoreEmit.hs": "9d93013a5fef60011d9428d43f484cbc152a7bb7f8c999be2b4ef5828d843bc6",
201
- "src/LawSpec/CoreNativeScalarEmit.hs": "5a5d145a18f596682a3dc3dacb009268d48c384c2f2ca620b503268096a66940",
202
- "src/LawSpec/CorePersist.hs": "682776b07e041e01470e0e2f16e50ce0531eccef2d5f5cb483497c41b212b937",
203
- "src/LawSpec/CoreScalarEmit.hs": "59a90297b51c8073a6e4b229aab4bfb0eb970a0b513c7ecca973a29dd0f96f0a",
208
+ "src/LawSpec/CoreEmit.hs": "6af51e63da17000b0bab20e0cc9a74dab93d02209c14e564bda024262e5887e4",
209
+ "src/LawSpec/CoreNativeScalarEmit.hs": "7c35c0405717f6cbf9dd0cbecb430678fda9fa95cd6c1363cceade2f1d6ea682",
210
+ "src/LawSpec/CorePersist.hs": "f18f6ae69ff8caa3f5d166f5b64f06716bc4755a7b825a370e233ba90f4b5bb5",
211
+ "src/LawSpec/CoreScalarEmit.hs": "7852454ec42777a5ad1246ba179aa8591f3145a45b8d3cbfb4c4b087a7601243",
204
212
  "src/LawSpec/Data.hs": "f659f4e86f1009c4806334a45686970dde2efa2641585f997a7beba01d0e6f2d",
205
213
  "src/LawSpec/DataNames.hs": "2eeb0d215131981a2271725a50c21dce44c7146a167025eb239a83922fdecaf6",
206
- "src/LawSpec/DefinitionTotality.hs": "adf00236e0e1b1cad4299793ced5f9047dbc2321d3c2f9ba040bac30d1a87c73",
207
- "src/LawSpec/Dependencies.hs": "918d55923c29c66a5a82dc346bad9c6f539965bc06212b2a54d03d65d9df599f",
214
+ "src/LawSpec/DefinitionTotality.hs": "af3aa9f7495344ea34c90cf87664f3ec2d9f95474ef273905fc6c9b17edd5d80",
215
+ "src/LawSpec/Dependencies.hs": "b748d2231f543a878e2ff3816f8a027285c610555821856383e8d1853e4c7151",
208
216
  "src/LawSpec/Digest.hs": "ba8128e36856d5fb0d2345779fd949b11042af688a0d8cee63e5ae8818cef7ca",
209
- "src/LawSpec/Discharge.hs": "e0c6760fa483e79782eb944c6208a815f2ff073428a5b90bbbb41aafca830bfe",
217
+ "src/LawSpec/Discharge.hs": "26b74132dfb0545dd48baf35c75aba261be109edea0693e2c9ff580750483f88",
210
218
  "src/LawSpec/Domain.hs": "222d15f0012ae630802238a6d7e1ee78d1e718b599f5ebb5a1ddc4e8d29d68c3",
211
- "src/LawSpec/DomainModel.hs": "835e6e31c9565bd624c1139ead71ad65c1065ee660457ae365522f7ed78f7939",
212
- "src/LawSpec/Elaboration.hs": "aade19ada1b9b944d1d5864b1ada61f89a57a675d7e8de9e2f3bc6b6f6d84b00",
219
+ "src/LawSpec/DomainModel.hs": "b2ac0eb9b63fae2860d9f53e6770d8fdf053d9df33773071b31de53cdf4e1562",
220
+ "src/LawSpec/Elaboration.hs": "b6c92cd113c61724b51baf73f94ae9507ff9be8661d0ec16215b8f3399f10f5f",
213
221
  "src/LawSpec/Emit.hs": "9f34f5765915a2a12a66a6dca647ddaef9289372956802c6d99cf0cfec447c7a",
214
222
  "src/LawSpec/Eval.hs": "b87a786ed7a512c60e00a037a1a36738933518aafa255babaa8b1b42dbb8ff6d",
215
223
  "src/LawSpec/Flow.hs": "830b9d59b94f26a05687bd5baed06b4ecbf1f47c6a634766810d3dd2a44647cd",
216
224
  "src/LawSpec/Frontend.hs": "85d631cb6246efcb14814177d1620ffd5f67964de725a8af241a11f1f30f5da3",
217
- "src/LawSpec/GoData.hs": "ffd2f91688e4efdbd65033b88ad55032278f9b29d8027f6dc9e4b2c3eb9bfbc0",
218
- "src/LawSpec/GoDefinitions.hs": "907fb5ba9935391fa640c0cf6d037db78d270467a8b93e1190a9d511f03561ff",
225
+ "src/LawSpec/GoData.hs": "5db907554f6d3d4bbb7e0617214be0260434ac8fb02d49e677325c4154bfee04",
226
+ "src/LawSpec/GoDefinitions.hs": "602977adc5d3bc9c6076bcc98c2e8955eba56ec4b8891534b01f49b7d7bb3206",
219
227
  "src/LawSpec/GoExpr.hs": "67ef004e97074976e0fd137dfef8d417efe8de3f7d5c3c08293874d30d89e9d0",
220
228
  "src/LawSpec/GoNativeBinding.hs": "1ad8ea4cec6187c7e6005651c0edeec69e196eb329fb958c833da7751225aa1b",
221
- "src/LawSpec/GoProperties.hs": "a6ff4745bddd931506ae5d9da70f1af73b5d8c79a47c2e56246f82f98a5fff93",
229
+ "src/LawSpec/GoProperties.hs": "3c9f73b42c1e13f86cc0592998090dd5619d55b56d190a05ca1de5d661e87ffa",
222
230
  "src/LawSpec/GoTestHelpers.hs": "dee55ee8505370e932773b8c685f4a1f380129e6f43f8806bf1e82efb99451b1",
223
231
  "src/LawSpec/GoTypeRefs.hs": "7f239f5ac3ac8bd21c8f76c328049f7715d8562ee1382befa0a58abd4f15f726",
224
232
  "src/LawSpec/HaskellData.hs": "8ca1f1a353972a28b3d044c3763243cd8a2abf3e2cdb3b15b6112d8a7edf9da2",
225
- "src/LawSpec/HaskellDefinitions.hs": "9481901b9f1753dbfe90dcc859275eaab474acdb2f41035cd14e9d03cce45440",
233
+ "src/LawSpec/HaskellDefinitions.hs": "fe989b62cb970bf4a3060a5793ff11ee5756cdec4c8c97de17f54181ef0112be",
226
234
  "src/LawSpec/HaskellExpr.hs": "f7ef064ac6700c027de4bd71bddeb3236853232cf7a39bed61de16153539b401",
227
235
  "src/LawSpec/HaskellNativeBinding.hs": "9f98aa0c8659b572bd6486a0e29c4692bc6432db8639fa74a09bbf1b771bbfa6",
228
- "src/LawSpec/HaskellProperties.hs": "1402eaff5984a1a012cd817b33ae9c7ebf634d29f35d4372e90d76ac56f2ff41",
236
+ "src/LawSpec/HaskellProperties.hs": "9eac50a0c24398a71823c71c75a29cf2718ff53f63890bf764735078f39b2f8a",
229
237
  "src/LawSpec/HaskellTestHelpers.hs": "51e59b2abc9e85455e3c8e2c6baadb27e5d319081cb730d2ce56be5dc8053897",
230
238
  "src/LawSpec/HaskellTypeRefs.hs": "2225b2a5e2ab3662e7202d23b24f4d6db48353b35ae28df8acd2b92fd2b97574",
231
- "src/LawSpec/Imports.hs": "1182894623b69e777531706c013b5ecd9995c51dd8c8b969c1807a5a103bf2da",
239
+ "src/LawSpec/Imports.hs": "0f81acb1e85d23b0c5745aa8530b0b979d739f201fc1d3d8f2d901c16c820b4a",
232
240
  "src/LawSpec/IndexTerm.hs": "1c694f279b934e7b853c0028158c2754048928deb45fb7d65abc1d98da382bcb",
233
241
  "src/LawSpec/Indexed.hs": "1e7ed53653cabc097f75dcf350c81facf9feb30af73f3e21f9344665fc316387",
234
- "src/LawSpec/Inference.hs": "8d3a8853bd691329d6d1cf0cdde9e4e8f8c895f5be944f2e77e9df348d1aa0eb",
235
- "src/LawSpec/JavaData.hs": "8afc712aed51240921cd6830b5d21ab029f71cc5cb0de56ca522eadd94ccb600",
236
- "src/LawSpec/JavaDefinitions.hs": "ba771b59878d8780613d1d40094597e8dca0478ccde11188a39df77667a01dab",
242
+ "src/LawSpec/Inference.hs": "40693bcf11935f812bac171e981476acd978a16d126855c9ddf385a8b1cc23c3",
243
+ "src/LawSpec/JavaData.hs": "078594c2a233824ff1d1a9c3fbc246e9d77ce4cc724ef1f72ad3aace68be5a93",
244
+ "src/LawSpec/JavaDefinitions.hs": "5247258db6ddb7075e5d05c6bb830aad6e0d9d3314082d164b1b2f5506337476",
237
245
  "src/LawSpec/JavaExpr.hs": "fb1d3e64f3288e557720dead7738eb4f2a59d4563e5be4a742e1582829f19d3e",
238
246
  "src/LawSpec/JavaNativeBinding.hs": "9eb52b3be19badda078069bb3d6813d72cad4f0a9bfa708f7404e44201d3c352",
239
- "src/LawSpec/JavaProperties.hs": "5a28381de13d49001540e9e5c8a67268394b62dfba3561cac8c2da735e62e775",
247
+ "src/LawSpec/JavaProperties.hs": "16b334f98eec4c029e630ce31fe7635f6d8d73bfcfb13707e0d348b2cbf23f95",
240
248
  "src/LawSpec/JavaTestHelpers.hs": "e6f4b9bbb7e5f07ece6ab1845e12aa661e62e8b926680b11454223fc3ec1523d",
241
- "src/LawSpec/KotlinData.hs": "ca3bad4dca9fcd604cd39ec713ef8ed38966aaf24b1d6b33d88d405bfc80641d",
242
- "src/LawSpec/KotlinDefinitions.hs": "97d7d407d4bbdb4ce16035d607dbbcb8e3d6f5db513f2123a2c269e3dc6d2b38",
249
+ "src/LawSpec/KotlinData.hs": "2cd47e1746fb840cc9dc62e02961bbb3a10b982b1b46f89be6816b45282476a3",
250
+ "src/LawSpec/KotlinDefinitions.hs": "4d49a62a1f8ea31a31dc79a6f4aba318f2f71552c495a67499f3cec6dc17fa60",
243
251
  "src/LawSpec/KotlinExpr.hs": "20312f0774f1d0832a21a19b93c8103e2791ecd32a827d8e9c4f2b4830a996a0",
244
252
  "src/LawSpec/KotlinNativeBinding.hs": "1aec7854758f07a4d2288de13931fbb88ef32220f85d3c84fe8233ad67b6d095",
245
- "src/LawSpec/KotlinProperties.hs": "da48d7cfef557d8453c49a1f1a664edbf3668ccfc86541adc65799ac6302b9af",
253
+ "src/LawSpec/KotlinProperties.hs": "59ac7374bb2184cb41458ce2d8d5170adc67d913ac87a18c4c69174ee9d941a7",
246
254
  "src/LawSpec/KotlinTestHelpers.hs": "74810d65faafc6ed4d64b1fb0596cda4186e586b7144a7441641b798795bc324",
247
255
  "src/LawSpec/Memo.hs": "1230a08b003cc6eee0db951b55a93f9ec573e5b6752c63d65d6c3487927b0b4e",
248
- "src/LawSpec/Model.hs": "7922e06bc600ea9400e6ec8c17ef4412e2ba8018b8d3a37a372e8bae4b6d8cb7",
256
+ "src/LawSpec/Model.hs": "6b3e70ba85a1613c969567a7a6d5ad75126e3df6cbc51a80eb964424f1bff4d6",
249
257
  "src/LawSpec/NativeBinding.hs": "33959b0fd432ad4150f3b685f6438e284b801c2a59d9ef3132486a1cc7c8925a",
250
258
  "src/LawSpec/NativeRequest.hs": "f8200c36725859ea32374655951f7a45e2b3342b159f9f6c88b5f9a2a6331897",
251
259
  "src/LawSpec/Packages.hs": "161fc68a9959a80762ca4ece405240351e3180ea4dbb2bf148eaca6562fb7c30",
252
- "src/LawSpec/Parser.hs": "953e907c51e12724085a6ce0504c767a8d622acf7ad4479913ed2cb86017251e",
260
+ "src/LawSpec/Parser.hs": "a2b7b241a60395b067690d74dc7385bb9365f10eda08ebb7d4372953b596b624",
253
261
  "src/LawSpec/Persist.hs": "d7f63a1205782c2ac0d71b737ade3ef90041403f3876b0f3a38c2b29d60922f2",
254
262
  "src/LawSpec/PortableGenerator.hs": "69d457e39f539c77fc7a4c08205e75352bbecd9dfdff031a283a39bf44b22d49",
255
263
  "src/LawSpec/PortableTestHelpers.hs": "8d98184c92a34b431f2a820cef3ea735b0cec3a52504f519b3bb06cb5174017c",
256
- "src/LawSpec/Prelude.hs": "b1e155c12f58e7c346551a0c65c5d5af76d045b3f1625977ca2a5d1c97cb8c46",
264
+ "src/LawSpec/Prelude.hs": "515698dda42a8b950c8529b14b5f9d6fe25e590eb1a7a2593ccbcb2edf87ea57",
257
265
  "src/LawSpec/Public.hs": "7010357e250607a9f94d1ab8dc34fad4014fb7d9f15ba0d7c2fc94d0f48fcac4",
258
- "src/LawSpec/PythonData.hs": "bb6e947829aa7611f39fb74152e8ef013c192be717a3573f12d249973ca65e5d",
259
- "src/LawSpec/PythonDefinitions.hs": "387a3f7678a7968249805365602206ebc0bb8d5b56924534d35294a1a98b0e5f",
266
+ "src/LawSpec/PythonData.hs": "09fc455151c0c527c53032512515482a970ecf45a1d529581622c47732c4bbb8",
267
+ "src/LawSpec/PythonDefinitions.hs": "72e0ae7154d3d2c4350975477802495061fe8a2bb0dc420a54c2d6cc75c4d1a3",
260
268
  "src/LawSpec/PythonExpr.hs": "23d7d24b5fb4efff9cb63d38c02a93d95744ec79b4565daf1412088fc7c4ba59",
261
269
  "src/LawSpec/PythonNativeBinding.hs": "4e35ff8781062d0f614e45ea45f98038c8d609ab78bd671cb0a239eaa9db1690",
262
- "src/LawSpec/PythonTypes.hs": "d465eef5fecef5d011fa422655d51cd1123800a39cfaf042545d41f2557bd98c",
270
+ "src/LawSpec/PythonTypes.hs": "bee4b5a5b00ad6ed358cdbcb6de02cd8be9be27e34c1c3ebe3256681aeb1e219",
271
+ "src/LawSpec/Railway.hs": "cada409ef5703cc5626b0ba36ba85f1fcfa6380c4baa9d4942342ea5c20be963",
263
272
  "src/LawSpec/Refinement.hs": "3bbdc090f9ebce60d99254dbe93dec6e11bd838df8537df828fd9c768c79d126",
264
- "src/LawSpec/RuntimeSources.hs": "b984cd8635be4109ea79fff5becb9accb1379f5322aaf6c50938264f01ba47b6",
265
- "src/LawSpec/RustData.hs": "b8bb35f2cc5835c811e01e8bbbe172f483ab2620e1e8e331cdfaf6342c23e7f1",
266
- "src/LawSpec/RustDefinitions.hs": "8211ad8c4db088ae658918b5172a666303aaf1bfe3f29bdd0b520a77015b2892",
267
- "src/LawSpec/RustEmit.hs": "bc1fd5c8ca25b23eb23f3e4fc54cdb9fc8ee53f6fc626732483694cc0ad9cc3f",
273
+ "src/LawSpec/Resilience.hs": "97b4a498ee74b608120ca578c7b9c708d2025b77db23d83e5c4ad80d5ff8a465",
274
+ "src/LawSpec/RuntimeSources.hs": "08ed920c4db1ac1abfe5ecb2af84b598b229632c634747b9177f39a594231d03",
275
+ "src/LawSpec/RustData.hs": "2c3ccc04a48c385bcc29f2dd8c7f0b88be898caaa461a8fd9910f2c35d560228",
276
+ "src/LawSpec/RustDefinitions.hs": "77c00183d9af6973ec77d387203a24ab3094dec9a7485e836b286fb90ea9733a",
277
+ "src/LawSpec/RustEmit.hs": "eb2bbc30150de2420473c0ace696c914a8eb9067b2e220d2872951030069e937",
268
278
  "src/LawSpec/RustExpr.hs": "04b2ef81417b811c7b98a98acdadab4e588ca8757964a63ba8dc5936c36479e6",
269
279
  "src/LawSpec/RustNativeBinding.hs": "d50d1fb10591ee86129ae49b38a343148c084479e450eef3b320e1efdd55245d",
270
280
  "src/LawSpec/RustNativeGenerators.hs": "a3b1484d9ff0008e4f961aa81d0aa51da57ec0cd7909124e80c98d56aacc8ce9",
271
- "src/LawSpec/Scaffold.hs": "217328445923b9e339428dd542ce9b910c26ed132c31d1ef083de73763b749f9",
281
+ "src/LawSpec/Scaffold.hs": "b4b02a2b565fd5bf3d056c68a24979339b6d4bd0a4182c0dc7b5faf79b8ec273",
272
282
  "src/LawSpec/Scalar.hs": "8ff178cbce4aa514f4b770e65efd471461cc12812e854d95f48b0dd54f0cc637",
273
283
  "src/LawSpec/SpecializeDefinitions.hs": "2bdd6d9b191941d869ef524659e02fed551499aaa2ea98c99323da03af113012",
284
+ "src/LawSpec/TargetNames.hs": "06410a1973d12bc241bfc399c8f5856d1692c6af792bb83b187bca894cfde4ca",
274
285
  "src/LawSpec/TestManifest.hs": "3c2018eea1528d047dff4c5fd2f353ee1ceb339cce7b1c32f0a2390df2d40ac8",
275
286
  "src/LawSpec/Testing.hs": "3bb83c3e74de6f0a09b12736115e47b4db2244e2f749d640e063cfc0500f174c",
287
+ "src/LawSpec/Time.hs": "9b05a784879a5791087492129bb9bd432d5e23082aa370e2a289552731bfb527",
276
288
  "src/LawSpec/WebData.hs": "bbcd7d734ce3941d83cc455a9a2147b642f6111ebb34db9ef99dcb7a58b8c4ae",
277
- "src/LawSpec/WebDefinitions.hs": "579309c76b9303a3c9e456e1252f2d0881795210aa0b09104a00efdfe10e3e13",
278
- "src/LawSpec/WebExpr.hs": "0389dcd5cf7479dd23ef034b1012de6ebd70bf1dc9e3d90981dfb0ba2702596f",
289
+ "src/LawSpec/WebDefinitions.hs": "896c7b7b3bf69f331fba98d1ee9f9b1bf30af349fc93dfdb490081760106f2fb",
290
+ "src/LawSpec/WebExpr.hs": "5bf5a2082f216646541bfa482f0f4eb492e32da9ab965e1e789256564d64332f",
279
291
  "src/LawSpec/WebNativeBinding.hs": "f536c1b1454bc83f5a9e8c61a608390b9a6fa91537f34d3c245b90ee6e275b7d",
280
292
  "src/LawSpec/WebTypes.hs": "1d43194e4dafbdcbed6e607414a875e9030028f03579f17d189c14a6a9bd5e53",
281
293
  "src/LawSpec/Witness.hs": "9ae944c9307df964bc853205269c1e4cb69cc076070bb878fc957f4bdb02de85",
@@ -284,8 +296,8 @@
284
296
  "wasm/app/Exports.hs": "4ecbdac8faa2449e6fc61b93c82e6278fa14374154f29b4dacf0eef433f06a47",
285
297
  "wasm/cabal.project": "021e560afdc5eb4cb7169e7119ecb8f92c9ee170245af909c94b612941bff5cc",
286
298
  "wasm/cabal.project.freeze": "733dbed3d2ecccb26e874fd58f136296dad772184deb1658c196b5d54a0814dc",
287
- "wasm/lawspec-wasm.cabal": "21821a861d641b1156f824ea92313a59a8c32ac0812ae6ee728adc2cf3bb4b66",
288
- "npm/core.wasm": "96c0b431747c457fc292221493e8d3b8b113488f48a1e832e5a41ba049e87913",
299
+ "wasm/lawspec-wasm.cabal": "36699a4aca6e7ad1c8ab81160ee5f8238e826fd977db5ca6e10b6c806786cbcb",
300
+ "npm/core.wasm": "7409a9cdb0da8e65445f2451c115248798f972853a81132848a63253a246341e",
289
301
  "npm/core_jsffi.js": "88d136efe92f7cff5758c8fec8d9b6bbc9707fe37741cebeeb415fe34ce3d72b",
290
302
  "npm/api.mjs": "19e1624f91258c1397f3212faf65b407c62671b0fc5b118520e6a91f7ad7c6ba",
291
303
  "npm/index.d.ts": "b6beef671c22633fdf369f584bfe9bc9bd0b281c54df06f1946970415e1e7793"
package/core.wasm CHANGED
Binary file
package/doctor.mjs CHANGED
@@ -398,7 +398,7 @@ export async function doctor(target, root, plannedArtifacts = []) {
398
398
  const init = path.join(tmp, "inspect.gradle");
399
399
  await writeFile(
400
400
  init,
401
- `import groovy.json.JsonOutput\ngradle.projectsEvaluated {\n def p = gradle.rootProject\n p.tasks.register('lawspecEnvironmentReport') { doLast {\n def k = p.tasks.findByName('compileTestKotlin')\n def j = p.tasks.findByName('test')\n def plugin = p.plugins.findPlugin('org.jetbrains.kotlin.jvm')\n def kv = plugin.class.classLoader.loadClass('org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapperKt').getMethod('getKotlinPluginVersion', org.gradle.api.Project).invoke(null, p)\n def deps = p.configurations.testRuntimeClasspath.resolvedConfiguration.resolvedArtifacts.collect { [name: it.moduleVersion.id.group + ':' + it.name, version: it.moduleVersion.id.version] }\n new File(System.getenv('LAWSPEC_REPORT')).text = JsonOutput.toJson([kotlin: kv, gradle: gradle.gradleVersion, java: System.getProperty('java.version'), target: k?.compilerOptions?.jvmTarget?.get()?.target, testJava: j?.javaLauncher?.get()?.metadata?.languageVersion?.asInt(), runner: j?.options?.class?.name, enabled: j.enabled, includes: j.filter.includePatterns, excludes: j.filter.excludePatterns, sourceDirs: p.sourceSets.main.allSource.srcDirs.collect { it.canonicalPath }, testDirs: p.sourceSets.test.allSource.srcDirs.collect { it.canonicalPath }, dependencies: deps])\n } }\n}\n`,
401
+ `import groovy.json.JsonOutput\ngradle.projectsEvaluated {\n def p = gradle.rootProject\n p.tasks.register('lawspecEnvironmentReport') { doLast {\n def k = p.tasks.findByName('compileTestKotlin')\n def j = p.tasks.findByName('test')\n def plugin = p.plugins.findPlugin('org.jetbrains.kotlin.jvm')\n def kv = plugin.class.classLoader.loadClass('org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapperKt').getMethod('getKotlinPluginVersion', org.gradle.api.Project).invoke(null, p)\n def deps = p.configurations.testRuntimeClasspath.resolvedConfiguration.resolvedArtifacts.collect { [name: it.moduleVersion.id.group + ':' + it.name, version: it.moduleVersion.id.version] }\n def mainDeps = p.configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts.collect { it.moduleVersion.id.group + ':' + it.name }\n new File(System.getenv('LAWSPEC_REPORT')).text = JsonOutput.toJson([kotlin: kv, gradle: gradle.gradleVersion, java: System.getProperty('java.version'), target: k?.compilerOptions?.jvmTarget?.get()?.target, testJava: j?.javaLauncher?.get()?.metadata?.languageVersion?.asInt(), runner: j?.options?.class?.name, enabled: j.enabled, includes: j.filter.includePatterns, excludes: j.filter.excludePatterns, sourceDirs: p.sourceSets.main.allSource.srcDirs.collect { it.canonicalPath }, testDirs: p.sourceSets.test.allSource.srcDirs.collect { it.canonicalPath }, dependencies: deps, mainDependencies: mainDeps])\n } }\n}\n`,
402
402
  );
403
403
  await run(
404
404
  command,
@@ -443,6 +443,11 @@ export async function doctor(target, root, plannedArtifacts = []) {
443
443
  ),
444
444
  `Missing ${dep}:5.9.1`,
445
445
  );
446
+ // Workflows block on asynchronous Kotlin steps with runBlocking.
447
+ requireThat(
448
+ (data.mainDependencies ?? []).includes("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm"),
449
+ "Missing org.jetbrains.kotlinx:kotlinx-coroutines-core (an implementation dependency, for workflows)",
450
+ );
446
451
  Object.assign(versions, data);
447
452
  requireThat(
448
453
  data.kotlin,
@@ -14,9 +14,11 @@ type ValidatedOrder is ValidatedOrder id :: OrderId quantity :: UnitQuantity end
14
14
  type PricedOrder is PricedOrder id :: OrderId quantity :: UnitQuantity total :: Int64 end
15
15
  type OrderError is | InvalidOrderId | InvalidQuantity | PriceTooHigh end
16
16
 
17
- -- The compiler checks that each step accepts the previous step's state and that
18
- -- all failures share one error type. It adds a law that placeOrder is the
19
- -- railway composition of the steps: the first Left is the workflow's result.
17
+ -- The compiler checks that each step accepts the previous step's state and
18
+ -- generates placeOrder on every target: the steps run in order and the first
19
+ -- Left is the workflow's result. Only the steps are written by hand. The steps
20
+ -- share OrderError, so it is the workflow's error type; laws say the workflow
21
+ -- succeeds when every step does and stops at the first failing step.
20
22
  workflow placeOrder :: UnvalidatedOrder -> Either OrderError PricedOrder is
21
23
  validateOrder :: UnvalidatedOrder -> Either OrderError ValidatedOrder
22
24
  priceOrder :: ValidatedOrder -> Either OrderError PricedOrder
@@ -24,6 +26,21 @@ end
24
26
 
25
27
  firstLine :: NonEmptyList Int32 -> Int32
26
28
 
29
+ -- An order is placed when it is valid and its total is at most 20000.
30
+ law `placing an order prices it` is
31
+ definition is
32
+ `for all` (input :: UnvalidatedOrder) .
33
+ prelude.isRight (placeOrder input) = (match input with
34
+ | UnvalidatedOrder id quantity ->
35
+ prelude.length id > 0 && quantity >= 1 && quantity <= 800
36
+ end)
37
+ end
38
+ example `a hundred units` is
39
+ input = UnvalidatedOrder "A-1" 100
40
+ expect prelude.isRight (placeOrder input) = true
41
+ end
42
+ end
43
+
27
44
  law `validation accepts exactly the valid orders` is
28
45
  definition is
29
46
  `for all` (input :: UnvalidatedOrder) .
@@ -0,0 +1,63 @@
1
+ unit example.durations
2
+
3
+ -- A Duration is a whole number of microseconds, from 0 to about 146 years.
4
+ -- Literals name a unit (us, ms, s, min, h, d), prelude.milliseconds and its
5
+ -- siblings build one from a number, and prelude.toMicroseconds reads one.
6
+ -- +, -, comparisons, * and prelude.quot by whole numbers stay in range or
7
+ -- fail, as division by zero does.
8
+
9
+ -- A checked definition: the totality audit proves the result in range.
10
+ definition timeoutFor (retries :: Int32 where retries >= 0 && retries <= 5) :: Duration is
11
+ 2s + 500ms * retries
12
+ end
13
+
14
+ -- An adapter: the time left of a budget, never negative.
15
+ remaining :: Duration -> Duration -> Duration
16
+
17
+ law `units relate` is
18
+ definition is
19
+ `for all` (b :: Bool) . (1us * 1000 == 1ms && 1000ms == 1s && 60s == 1min && 60min == 1h && 24h == 1d) = true
20
+ end
21
+ end
22
+
23
+ law `subtraction undoes addition` is
24
+ definition is
25
+ `for all` (n :: Int32 where n >= 0) (m :: Int32 where m >= 0) .
26
+ prelude.milliseconds (prelude.Integer n) + prelude.milliseconds (prelude.Integer m) - prelude.milliseconds (prelude.Integer m) =
27
+ prelude.milliseconds (prelude.Integer n)
28
+ end
29
+ end
30
+
31
+ law `timeouts grow by half a second` is
32
+ definition is
33
+ `for all` (r :: Int32 where r >= 0 && r <= 4) . timeoutFor (r + 1) - timeoutFor r = 500ms
34
+ end
35
+ example `no retries` is
36
+ r = 0
37
+ expect prelude.toMicroseconds (timeoutFor r) = 2000000
38
+ end
39
+ end
40
+
41
+ law `spending everything leaves nothing` is
42
+ definition is
43
+ `for all` (d :: Duration) . remaining d d = 0us and remaining d 0us = d
44
+ end
45
+ end
46
+
47
+ law `what remains of a budget` is
48
+ definition is
49
+ `for all` (budget :: Duration) (spent :: Duration) .
50
+ prelude.toMicroseconds (remaining budget spent) =
51
+ prelude.select (spent <= budget) (prelude.toMicroseconds budget - prelude.toMicroseconds spent) 0
52
+ end
53
+ example `part of a second` is
54
+ budget = 1s
55
+ spent = 250ms
56
+ expect remaining budget spent = 750ms
57
+ end
58
+ example `an overrun leaves nothing` is
59
+ budget = 1s
60
+ spent = 2s
61
+ expect remaining budget spent = 0us
62
+ end
63
+ end
@@ -0,0 +1,33 @@
1
+ unit example.keywords
2
+
3
+ -- A name that is a keyword of a target language is emitted there with a
4
+ -- leading underscore: short is _short in Java, lambda is _lambda in Python,
5
+ -- and class is _class wherever class is reserved. Other targets keep the name.
6
+
7
+ definition short (x :: BigInt) :: Bool is x < 10 end
8
+ definition double (x :: BigInt) :: BigInt is x + x end
9
+ definition lambda (x :: BigInt) :: BigInt is x + 1 end
10
+ definition fun (x :: BigInt) :: BigInt is x + 2 end
11
+ definition loop (x :: BigInt) :: BigInt is x + 3 end
12
+ definition deriving (x :: BigInt) :: BigInt is x + 4 end
13
+ definition delete (x :: BigInt) :: BigInt is x + 5 end
14
+
15
+ -- An adapter, written by hand on each target as _class or class.
16
+ class :: BigInt -> BigInt
17
+
18
+ law `keyword names are callable` is
19
+ definition is
20
+ `for all` (x :: BigInt) .
21
+ double x - x + lambda x + fun x + loop x + deriving x + delete x = 6 * x + 15
22
+ end
23
+ example `short` is
24
+ x = 3
25
+ expect short x = true
26
+ end
27
+ end
28
+
29
+ law `the class adapter doubles` is
30
+ definition is
31
+ `for all` (x :: BigInt) . class x = double x
32
+ end
33
+ end
@@ -0,0 +1,43 @@
1
+ unit example.limits
2
+
3
+ -- A workflow with a rate limit, for the resilience suite: two calls per
4
+ -- second, rejecting the rest. Its own unit, so the suite's checks can call it
5
+ -- on every target (a Haskell workflow imports its steps' module).
6
+ type Ticket is Ticket number :: Int64 end
7
+
8
+ admitTicket :: Ticket -> Either Text Ticket
9
+
10
+ workflow limited :: Ticket -> Either _ Ticket is
11
+ admitTicket :: Ticket -> Either Text Ticket
12
+ rateLimit tokenBucket 2 1s reject
13
+ end
14
+
15
+ -- A workflow that compensates: when charging fails, the reserved seat is
16
+ -- released.
17
+ reserveSeat :: Ticket -> Either Text Ticket
18
+ chargeCard :: Ticket -> Either Text Ticket
19
+ releaseSeat :: Ticket -> Bool
20
+
21
+ workflow book :: Ticket -> Either _ Ticket is
22
+ reserveSeat :: Ticket -> Either Text Ticket
23
+ compensate releaseSeat
24
+ chargeCard :: Ticket -> Either Text Ticket
25
+ end
26
+
27
+ -- An asynchronous step within a timeout: the quote for ticket -1 is slow
28
+ -- (600ms), so its stage times out.
29
+ async fetchQuote :: Ticket -> Either Text Ticket
30
+
31
+ workflow quoted :: Ticket -> Either _ Ticket is
32
+ fetchQuote :: Ticket -> Either Text Ticket
33
+ timeout 200ms
34
+ end
35
+
36
+ -- An asynchronous step with a hedge: ticket -2's first quote stalls (600ms),
37
+ -- so a second starts after 50ms and answers first.
38
+ async hedgeQuote :: Ticket -> Either Text Ticket
39
+
40
+ workflow hedged :: Ticket -> Either _ Ticket is
41
+ hedgeQuote :: Ticket -> Either Text Ticket
42
+ hedge 50ms
43
+ end
@@ -0,0 +1,78 @@
1
+ unit example.railway
2
+
3
+ -- Railway combinators on Either. Each symbol has a prelude name, and both are
4
+ -- rewritten into matches, so they work in laws and checked definitions alike.
5
+
6
+ type Problem is | TooSmall | TooLarge | Odd end
7
+
8
+ definition positive (x :: BigInt) :: Either Problem BigInt is
9
+ prelude.select (x > 0) (Right x) (Left TooSmall)
10
+ end
11
+
12
+ definition small (x :: BigInt) :: Either Problem BigInt is
13
+ prelude.select (x < 100) (Right x) (Left TooLarge)
14
+ end
15
+
16
+ definition even (x :: BigInt) :: Bool is prelude.rem x 2 == 0 end
17
+
18
+ definition twice (x :: BigInt) :: BigInt is x + x end
19
+
20
+ definition retry (p :: Problem) :: Either Problem BigInt is Right 1 end
21
+
22
+ -- A checked pipeline written with symbols: positive, then small, then doubled.
23
+ definition checked (x :: BigInt) :: Either Problem BigInt is
24
+ twice <$> (positive x >>= small)
25
+ end
26
+
27
+ -- The same pipeline in English.
28
+ definition checkedInWords (x :: BigInt) :: Either Problem BigInt is
29
+ prelude.map twice (prelude.bind (positive x) small)
30
+ end
31
+
32
+ law `symbols and English agree` is
33
+ definition is `for all` (x :: BigInt) . checked x = checkedInWords x end
34
+ end
35
+
36
+ law `binding associates` is
37
+ definition is
38
+ `for all` (x :: BigInt) . ((positive x >>= small) >>= positive) = (positive x >>= (small >=> positive))
39
+ end
40
+ end
41
+
42
+ law `a failure short-circuits` is
43
+ definition is `for all` (x :: BigInt) . x <= 0 implies checked x = Left TooSmall end
44
+ end
45
+
46
+ law `recovery replaces a failure` is
47
+ definition is `for all` (x :: BigInt) . (positive x <|> retry) = prelude.select (x > 0) (Right x) (Right 1) end
48
+ end
49
+
50
+ law `ensure keeps even values` is
51
+ definition is
52
+ `for all` (x :: BigInt) .
53
+ prelude.ensure even Odd (positive x) = prelude.select (x > 0) (prelude.select (even x) (Right x) (Left Odd)) (Left TooSmall)
54
+ end
55
+ end
56
+
57
+ law `both pairs successes` is
58
+ definition is
59
+ `for all` (x :: BigInt) . prelude.isRight (positive x <*> small x) = (x > 0 && x < 100)
60
+ end
61
+ end
62
+
63
+ -- The prelude's railway laws, instantiated for these definitions.
64
+ law `positive is a left identity case` is
65
+ definition is `bind has a left identity` positive end
66
+ end
67
+
68
+ law `positive, small and positive associate` is
69
+ definition is `bind is associative` positive small positive end
70
+ end
71
+
72
+ law `mapping twice fuses` is
73
+ definition is `map fuses` positive twice twice end
74
+ end
75
+
76
+ law `retry keeps successes` is
77
+ definition is `recovery keeps successes` positive retry end
78
+ end
@@ -0,0 +1,245 @@
1
+ unit example.resilience
2
+
3
+ import lawspec.resilience as r
4
+ import example.limits as limits
5
+
6
+ -- Conformance of each target's workflow runtime with a reference model.
7
+ -- The adapters call the runtime; the checked definitions are the reference.
8
+ -- Delays are whole microseconds.
9
+
10
+ -- The delay before attempt k (2 or more) of each retry strategy.
11
+ definition exponentialDelay (base :: Integer where base >= 0 && base <= 1000000)
12
+ (factor :: Integer where factor >= 1 && factor <= 4)
13
+ (attempt :: Integer where attempt >= 2 && attempt <= 10) :: Integer is
14
+ base * prelude.pow factor (attempt - 2)
15
+ end
16
+
17
+ definition linearDelay (base :: Integer where base >= 0 && base <= 1000000)
18
+ (step :: Integer where step >= 0 && step <= 1000000)
19
+ (attempt :: Integer where attempt >= 2 && attempt <= 10) :: Integer is
20
+ base + step * (attempt - 2)
21
+ end
22
+
23
+ runtimeExponentialDelay :: Integer -> Integer -> Integer -> Integer
24
+ runtimeLinearDelay :: Integer -> Integer -> Integer -> Integer
25
+ runtimeFibonacciDelay :: Integer -> Integer -> Integer
26
+
27
+ -- The first outputs of SplitMix64 for a seed, and full jitter.
28
+ splitMix :: UInt64 -> Int32 -> List UInt64
29
+ fullJitter :: UInt64 -> Integer -> Integer
30
+
31
+ -- A stage that always fails, retried exponentially from 100ms, doubling, for
32
+ -- the given number of attempts: the waits the runtime makes.
33
+ retriedWaits :: Int32 -> List Integer
34
+
35
+ -- The same, with a when predicate that rejects the error: no waits.
36
+ rejectedWaits :: Int32 -> List Integer
37
+
38
+ -- Unrefined inputs are mapped into range, so every target generates them
39
+ -- directly: a base up to 65535us, a factor of 1 to 4, and attempts 2 to 10.
40
+ law `exponential delays match the reference` is
41
+ definition is
42
+ `for all` (base :: UInt16) (f :: UInt8) (a :: UInt8) .
43
+ runtimeExponentialDelay (prelude.Integer base) (1 + prelude.rem (prelude.Integer f) 4) (2 + prelude.rem (prelude.Integer a) 9) =
44
+ exponentialDelay (prelude.Integer base) (1 + prelude.rem (prelude.Integer f) 4) (2 + prelude.rem (prelude.Integer a) 9)
45
+ end
46
+ end
47
+
48
+ law `the fifth exponential attempt` is
49
+ definition is
50
+ `for all` (base :: Integer where base == 100000) . runtimeExponentialDelay base 2 5 = 800000
51
+ end
52
+ end
53
+
54
+ law `linear delays match the reference` is
55
+ definition is
56
+ `for all` (base :: UInt16) (step :: UInt16) (a :: UInt8) .
57
+ runtimeLinearDelay (prelude.Integer base) (prelude.Integer step) (2 + prelude.rem (prelude.Integer a) 9) =
58
+ linearDelay (prelude.Integer base) (prelude.Integer step) (2 + prelude.rem (prelude.Integer a) 9)
59
+ end
60
+ end
61
+
62
+ law `fibonacci delays add the two before` is
63
+ definition is
64
+ `for all` (base :: UInt16) (a :: UInt8) .
65
+ runtimeFibonacciDelay (prelude.Integer base) (4 + prelude.rem (prelude.Integer a) 27) =
66
+ runtimeFibonacciDelay (prelude.Integer base) (3 + prelude.rem (prelude.Integer a) 27) +
67
+ runtimeFibonacciDelay (prelude.Integer base) (2 + prelude.rem (prelude.Integer a) 27)
68
+ end
69
+ end
70
+
71
+ law `fibonacci delays start at the base` is
72
+ definition is
73
+ `for all` (base :: UInt16) .
74
+ runtimeFibonacciDelay (prelude.Integer base) 2 = prelude.Integer base and
75
+ runtimeFibonacciDelay (prelude.Integer base) 3 = prelude.Integer base
76
+ end
77
+ end
78
+
79
+ law `SplitMix64 is the same everywhere` is
80
+ definition is
81
+ `for all` (count :: Int8 where count >= 0 && count <= 3) .
82
+ prelude.length (splitMix 0 (prelude.Int32 count)) = prelude.Integer count
83
+ end
84
+ example `seed zero` is
85
+ count = 3
86
+ expect splitMix 0 (prelude.Int32 count) = [16294208416658607535, 7960286522194355700, 487617019471545679]
87
+ end
88
+ end
89
+
90
+ law `full jitter stays within the delay` is
91
+ definition is
92
+ `for all` (seed :: UInt64) (delay :: UInt32) .
93
+ (fullJitter seed (prelude.Integer delay) >= 0 && fullJitter seed (prelude.Integer delay) <= prelude.Integer delay) = true
94
+ end
95
+ end
96
+
97
+ law `a failing stage waits between its attempts` is
98
+ definition is
99
+ `for all` (attempts :: Int8 where attempts >= 1 && attempts <= 6) .
100
+ prelude.length (retriedWaits (prelude.Int32 attempts)) = prelude.Integer attempts - 1
101
+ end
102
+ example `four attempts` is
103
+ attempts = 4
104
+ expect retriedWaits (prelude.Int32 attempts) = [100000, 200000, 400000]
105
+ end
106
+ end
107
+
108
+ law `a rejected error is not retried` is
109
+ definition is
110
+ `for all` (attempts :: Int8 where attempts >= 1 && attempts <= 6) .
111
+ rejectedWaits (prelude.Int32 attempts) = []
112
+ end
113
+ end
114
+
115
+ -- Calls limited at each time (microseconds, in order) under one runtime
116
+ -- with its gates on: whether each call was admitted.
117
+ limitedAt :: List Integer -> List Bool
118
+
119
+ definition admits (gate :: r.Gate) :: Bool is
120
+ match gate with
121
+ | Admit -> true
122
+ | WaitFor micros -> false
123
+ | Reject -> false
124
+ end
125
+ end
126
+
127
+ -- The reference: the resilience unit's token bucket, folded over the times.
128
+ definition bucketRun (state :: r.TokenBucket) (times :: List Integer) :: List Bool is
129
+ match times with
130
+ | Nil -> Nil
131
+ | Cons t rest ->
132
+ match r.tokenBucketAdmit 2 1000000 state t with
133
+ | Step next gate -> Cons (admits gate) (bucketRun next rest)
134
+ end
135
+ end
136
+ end
137
+
138
+ -- Times a millisecond apart and more, as a list of gaps.
139
+ definition timesFrom (start :: Integer) (gaps :: List UInt16) :: List Integer is
140
+ match gaps with
141
+ | Nil -> Nil
142
+ | Cons gap rest -> Cons start (timesFrom (start + prelude.Integer gap * 1000) rest)
143
+ end
144
+ end
145
+
146
+ law `the rate limit admits as the token bucket does` is
147
+ definition is
148
+ `for all` (gaps :: List UInt16) .
149
+ limitedAt (timesFrom 0 gaps) = bucketRun (r.tokenBucketStart 2 1000000 0) (timesFrom 0 gaps)
150
+ end
151
+ example `three calls at once` is
152
+ gaps = [0, 0, 0]
153
+ expect limitedAt (timesFrom 0 gaps) = [true, true, false]
154
+ end
155
+ end
156
+
157
+ -- The other state machines, which every target runs as generated code.
158
+ law `an open breaker rejects until its cooldown ends` is
159
+ definition is
160
+ `for all` (t :: UInt16) .
161
+ r.breakerAdmit (r.Open 1000) (prelude.Integer t) =
162
+ prelude.select (prelude.Integer t >= 1000) (r.Step r.HalfOpen r.Admit) (r.Step (r.Open 1000) r.Reject)
163
+ end
164
+ end
165
+
166
+ law `a breaker opens after enough failures in its window` is
167
+ definition is
168
+ `for all` (gap :: UInt8) .
169
+ r.breakerRecord 2 1000 500 (r.breakerRecord 2 1000 500 (r.Closed []) 10 false) (10 + prelude.Integer gap) false =
170
+ r.Open (510 + prelude.Integer gap)
171
+ end
172
+ end
173
+
174
+ law `a breaker forgets failures outside its window` is
175
+ definition is
176
+ `for all` (gap :: UInt8) .
177
+ r.breakerRecord 2 100 500 (r.breakerRecord 2 100 500 (r.Closed []) 0 false) (200 + prelude.Integer gap) false =
178
+ r.Closed [200 + prelude.Integer gap]
179
+ end
180
+ end
181
+
182
+ law `a successful trial closes the breaker` is
183
+ definition is
184
+ `for all` (t :: UInt16) . r.breakerRecord 2 1000 500 r.HalfOpen (prelude.Integer t) true = r.Closed []
185
+ end
186
+ end
187
+
188
+ law `a bulkhead admits up to its limit` is
189
+ definition is
190
+ `for all` (running :: UInt8) .
191
+ r.bulkheadAdmit 4 (r.Bulkhead (prelude.Integer running)) 0 =
192
+ prelude.select (prelude.Integer running < 4)
193
+ (r.Step (r.Bulkhead (prelude.Integer running + 1)) r.Admit)
194
+ (r.Step (r.Bulkhead (prelude.Integer running)) (r.WaitFor 1000))
195
+ end
196
+ end
197
+
198
+ law `a sliding window admits n calls per period` is
199
+ definition is
200
+ `for all` (t :: UInt16) .
201
+ r.slidingWindowAdmit 2 1000 (r.SlidingWindow [prelude.Integer t, prelude.Integer t]) (prelude.Integer t + 1) =
202
+ r.Step (r.SlidingWindow [prelude.Integer t, prelude.Integer t]) (r.WaitFor 999)
203
+ end
204
+ end
205
+
206
+ -- Books a ticket under a fresh runtime: the stages whose undos ran.
207
+ compensationsFor :: Int64 -> List Text
208
+
209
+ law `a failed booking releases its seat` is
210
+ definition is
211
+ `for all` (n :: Int64) .
212
+ compensationsFor n = prelude.select (n < 0) ["reserveSeat"] []
213
+ end
214
+ end
215
+
216
+ -- Quotes a ticket under a runtime with the real clock: whether it timed out.
217
+ async quoteTimedOut :: Int64 -> Bool
218
+
219
+ law `a slow quote times out` is
220
+ definition is
221
+ `for all` (n :: Int64) . quoteTimedOut n = (n == -1)
222
+ end
223
+ example `a slow quote` is
224
+ n = -1
225
+ expect quoteTimedOut n = true
226
+ end
227
+ example `a quick quote` is
228
+ n = 0
229
+ expect quoteTimedOut n = false
230
+ end
231
+ end
232
+
233
+ -- Quotes a ticket under a runtime with the real clock: whether it succeeded
234
+ -- quickly (within 400ms), for ticket -2 through a hedged attempt.
235
+ async quoteHedged :: Int64 -> Bool
236
+
237
+ law `a stalled quote is hedged` is
238
+ definition is
239
+ `for all` (n :: Int64) . quoteHedged n = true
240
+ end
241
+ example `a stalled quote` is
242
+ n = -2
243
+ expect quoteHedged n = true
244
+ end
245
+ end
@@ -0,0 +1,145 @@
1
+ unit example.workflows
2
+
3
+ -- Workflows compose steps written by hand on each target. LawSpec generates
4
+ -- the composition itself, so a workflow behaves the same everywhere: every
5
+ -- stage below is a keyword, and each has a symbol too (>>=, <$>, <!>, <|>, ??).
6
+
7
+ type Signup is Signup name :: Text age :: Int32 end
8
+ type Account is Account name :: Text age :: Int32 level :: Int32 end
9
+ type SignupError is | MissingName | TooYoung | NameTooLong | Unavailable end
10
+
11
+ -- Checked definitions: LawSpec writes these on every target.
12
+ definition explain (reason :: Text) :: SignupError is TooYoung end
13
+
14
+ definition promote (a :: Account) :: Account is
15
+ match a with
16
+ | Account name age level -> Account name age 2
17
+ end
18
+ end
19
+
20
+ definition brief (a :: Account) :: Bool is
21
+ match a with
22
+ | Account name age level -> prelude.length name <= 8
23
+ end
24
+ end
25
+
26
+ definition tooLong (a :: Account) :: SignupError is NameTooLong end
27
+
28
+ definition nameOf (s :: Signup) :: Text is
29
+ match s with
30
+ | Signup name age -> name
31
+ end
32
+ end
33
+
34
+ -- Side steps and recovery handlers, also written by hand.
35
+ audit :: Account -> Bool
36
+ waitlist :: SignupError -> Either SignupError Account
37
+
38
+ -- The workflow's error type is declared, so every step must fail with
39
+ -- SignupError; checkAge fails with a reason, which mapError turns into one.
40
+ workflow register :: Signup -> Either SignupError Account is
41
+ checkName :: Signup -> Either SignupError Signup
42
+ retry exponential 100ms 2 3 max 1s jitter full
43
+ then checkAge :: Signup -> Either Text Signup
44
+ mapError explain
45
+ then openAccount :: Signup -> Either SignupError Account
46
+ map promote
47
+ tap audit
48
+ ensure brief else tooLong
49
+ orElse waitlist
50
+ end
51
+
52
+ -- With the error written as _, LawSpec generates GreetError, with one
53
+ -- constructor per step that can fail: GreetCheckNameFailed and GreetCheckAgeFailed.
54
+ workflow greet :: Signup -> Either _ Text is
55
+ checkName :: Signup -> Either SignupError Signup
56
+ >>= checkAge :: Signup -> Either Text Signup
57
+ <$> nameOf
58
+ ?? anonymous
59
+ end
60
+
61
+ definition anonymous (e :: GreetError) :: Text is "guest" end
62
+
63
+ law `registering an account` is
64
+ definition is
65
+ `for all` (s :: Signup) .
66
+ prelude.isRight (register s) = (match s with
67
+ | Signup name age ->
68
+ prelude.length name > 0 && age >= 18 && prelude.length name <= 8
69
+ end)
70
+ end
71
+ example `a new account is promoted` is
72
+ s = Signup "ada" 30
73
+ expect register s = Right (Account "ada" 30 2)
74
+ end
75
+ example `a name is required` is
76
+ s = Signup "" 30
77
+ expect register s = Left MissingName
78
+ end
79
+ example `seventeen is too young` is
80
+ s = Signup "bob" 17
81
+ expect register s = Left TooYoung
82
+ end
83
+ example `a long name is rejected` is
84
+ s = Signup "bartholomew" 30
85
+ expect register s = Left NameTooLong
86
+ end
87
+ example `a taken name joins the waitlist` is
88
+ s = Signup "taken" 30
89
+ expect register s = Right (Account "waitlist" 18 0)
90
+ end
91
+ end
92
+
93
+ law `greeting never fails` is
94
+ definition is
95
+ `for all` (s :: Signup) . prelude.isRight (greet s) = true
96
+ end
97
+ example `a named greeting` is
98
+ s = Signup "ada" 30
99
+ expect greet s = Right "ada"
100
+ end
101
+ example `an anonymous greeting` is
102
+ s = Signup "" 30
103
+ expect greet s = Right "guest"
104
+ end
105
+ end
106
+
107
+ -- An all group runs its steps on the same state and combines their results.
108
+ -- With accumulate, every failing step's error is reported, in a generated
109
+ -- VetFailures constructor.
110
+ definition firstName (a :: Signup) (b :: Signup) :: Text is nameOf a end
111
+
112
+ workflow vet :: Signup -> Either _ Text is
113
+ all accumulate
114
+ then checkName
115
+ then checkAge
116
+ end
117
+ combine firstName
118
+ end
119
+
120
+ law `vetting reports every problem` is
121
+ definition is
122
+ `for all` (s :: Signup) .
123
+ prelude.isRight (vet s) = (match s with
124
+ | Signup name age -> prelude.length name > 0 && age >= 18
125
+ end)
126
+ end
127
+ example `no problems` is
128
+ s = Signup "ada" 30
129
+ expect vet s = Right "ada"
130
+ end
131
+ end
132
+
133
+ law `vetting a nameless child reports both problems` is
134
+ definition is
135
+ `for all` (age :: Int8 where age >= 0 && age < 18) .
136
+ vet (Signup "" (prelude.Int32 age)) = Left (VetFailures [VetCheckNameFailed MissingName, VetCheckAgeFailed "too young"])
137
+ end
138
+ end
139
+
140
+ law `vetting a named child reports its age` is
141
+ definition is
142
+ `for all` (age :: Int8 where age >= 0 && age < 18) .
143
+ vet (Signup "ada" (prelude.Int32 age)) = Left (VetFailures [VetCheckAgeFailed "too young"])
144
+ end
145
+ end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lawspec",
3
- "version": "0.17.5",
3
+ "version": "0.18.0",
4
4
  "description": "State the law once. Check it everywhere.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/templates.mjs CHANGED
@@ -93,11 +93,11 @@ const scaffolds = {
93
93
  "kotlin": {
94
94
  "readable": {
95
95
  "settings.gradle.kts": "rootProject.name = \"lawspec-example\"\n",
96
- "build.gradle.kts": "plugins {\n kotlin(\"jvm\") version \"2.3.21\"\n}\n\nrepositories {\n mavenCentral()\n}\n\nkotlin {\n jvmToolchain(25)\n}\n\ndependencies {\n testImplementation(\"io.kotest:kotest-runner-junit5:5.9.1\")\n testImplementation(\"io.kotest:kotest-assertions-core:5.9.1\")\n testImplementation(\"io.kotest:kotest-property:5.9.1\")\n}\n\ntasks.test {\n useJUnitPlatform()\n}\n"
96
+ "build.gradle.kts": "plugins {\n kotlin(\"jvm\") version \"2.3.21\"\n}\n\nrepositories {\n mavenCentral()\n}\n\nkotlin {\n jvmToolchain(25)\n}\n\ndependencies {\n implementation(\"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0\")\n testImplementation(\"io.kotest:kotest-runner-junit5:5.9.1\")\n testImplementation(\"io.kotest:kotest-assertions-core:5.9.1\")\n testImplementation(\"io.kotest:kotest-property:5.9.1\")\n}\n\ntasks.test {\n useJUnitPlatform()\n}\n"
97
97
  },
98
98
  "compact": {
99
99
  "settings.gradle.kts": "rootProject.name = \"lawspec-example\"\n",
100
- "build.gradle.kts": "plugins { kotlin(\"jvm\") version \"2.3.21\" }\nrepositories { mavenCentral() }\nkotlin { jvmToolchain(25) }\ndependencies { testImplementation(\"io.kotest:kotest-runner-junit5:5.9.1\"); testImplementation(\"io.kotest:kotest-assertions-core:5.9.1\"); testImplementation(\"io.kotest:kotest-property:5.9.1\") }\ntasks.test { useJUnitPlatform() }\n"
100
+ "build.gradle.kts": "plugins { kotlin(\"jvm\") version \"2.3.21\" }\nrepositories { mavenCentral() }\nkotlin { jvmToolchain(25) }\ndependencies { implementation(\"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0\"); testImplementation(\"io.kotest:kotest-runner-junit5:5.9.1\"); testImplementation(\"io.kotest:kotest-assertions-core:5.9.1\"); testImplementation(\"io.kotest:kotest-property:5.9.1\") }\ntasks.test { useJUnitPlatform() }\n"
101
101
  }
102
102
  },
103
103
  "rust": {