lawspec 0.17.2 → 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 +137 -0
- package/README.md +3 -3
- package/bin/lawspec.mjs +146 -10
- package/build.json +86 -68
- package/core.wasm +0 -0
- package/doctor.mjs +6 -1
- package/examples/specs/domain_modeling.lawspec +20 -3
- package/examples/specs/durations.lawspec +63 -0
- package/examples/specs/keywords.lawspec +33 -0
- package/examples/specs/limits.lawspec +43 -0
- package/examples/specs/railway.lawspec +78 -0
- package/examples/specs/resilience.lawspec +245 -0
- package/examples/specs/workflows.lawspec +145 -0
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/templates.mjs +2 -2
- package/test-command.mjs +205 -0
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",
|
|
@@ -56,6 +58,7 @@
|
|
|
56
58
|
"src/LawSpec/Core/Value.hs",
|
|
57
59
|
"src/LawSpec/CoreEmit.hs",
|
|
58
60
|
"src/LawSpec/CoreNativeScalarEmit.hs",
|
|
61
|
+
"src/LawSpec/CorePersist.hs",
|
|
59
62
|
"src/LawSpec/CoreScalarEmit.hs",
|
|
60
63
|
"src/LawSpec/Data.hs",
|
|
61
64
|
"src/LawSpec/DataNames.hs",
|
|
@@ -106,6 +109,7 @@
|
|
|
106
109
|
"src/LawSpec/NativeRequest.hs",
|
|
107
110
|
"src/LawSpec/Packages.hs",
|
|
108
111
|
"src/LawSpec/Parser.hs",
|
|
112
|
+
"src/LawSpec/Persist.hs",
|
|
109
113
|
"src/LawSpec/PortableGenerator.hs",
|
|
110
114
|
"src/LawSpec/PortableTestHelpers.hs",
|
|
111
115
|
"src/LawSpec/Prelude.hs",
|
|
@@ -115,7 +119,9 @@
|
|
|
115
119
|
"src/LawSpec/PythonExpr.hs",
|
|
116
120
|
"src/LawSpec/PythonNativeBinding.hs",
|
|
117
121
|
"src/LawSpec/PythonTypes.hs",
|
|
122
|
+
"src/LawSpec/Railway.hs",
|
|
118
123
|
"src/LawSpec/Refinement.hs",
|
|
124
|
+
"src/LawSpec/Resilience.hs",
|
|
119
125
|
"src/LawSpec/RuntimeSources.hs",
|
|
120
126
|
"src/LawSpec/RustData.hs",
|
|
121
127
|
"src/LawSpec/RustDefinitions.hs",
|
|
@@ -126,7 +132,10 @@
|
|
|
126
132
|
"src/LawSpec/Scaffold.hs",
|
|
127
133
|
"src/LawSpec/Scalar.hs",
|
|
128
134
|
"src/LawSpec/SpecializeDefinitions.hs",
|
|
135
|
+
"src/LawSpec/TargetNames.hs",
|
|
136
|
+
"src/LawSpec/TestManifest.hs",
|
|
129
137
|
"src/LawSpec/Testing.hs",
|
|
138
|
+
"src/LawSpec/Time.hs",
|
|
130
139
|
"src/LawSpec/WebData.hs",
|
|
131
140
|
"src/LawSpec/WebDefinitions.hs",
|
|
132
141
|
"src/LawSpec/WebExpr.hs",
|
|
@@ -142,134 +151,143 @@
|
|
|
142
151
|
],
|
|
143
152
|
"digests": {
|
|
144
153
|
"dev/Gen/Embed.hs": "41cd18500c1a8c9bdb51011ab4c74817f8e04b655aa10d9894aa1b93a3fa858b",
|
|
145
|
-
"lawspec.cabal": "
|
|
146
|
-
"package.yaml": "
|
|
154
|
+
"lawspec.cabal": "a5b307f47140711064647dda585c4f882af8072c9118d9c637e4c52bdac6032f",
|
|
155
|
+
"package.yaml": "7e5212a8889ae07c4200ad953e4b40b5af7b0497fef565e5469e93526f3727b9",
|
|
147
156
|
"runtime/LawSpecCodecs.hs": "1b3f6b40ad49928cf5e9386e06bc2992c9f1271754351b9fa3075e50346ef03b",
|
|
148
157
|
"runtime/LawSpecCollectionCodecs.hs": "74caa786801c5142ed040897c7ebb7373abf49ee49e02af53e466646fb624f47",
|
|
149
158
|
"runtime/LawSpecDataStrategies.hs": "9cc5b98476364a6c255dc3eb40c53d65b4a9d4ab0c3961a806b3515a8d5e8f7f",
|
|
150
159
|
"runtime/LawSpecDataStrategies.java": "d06c1eb6c67f3d07ab0c90dc8f8626b48358763b91585c6ea216a47e11886dd0",
|
|
151
160
|
"runtime/LawSpecKotlin.kt": "0cf3b7de0406155225ccca33ee3dfdf8f0456c47d577f6be8f1265c13df838cb",
|
|
152
|
-
"runtime/LawSpecKotlinCodecs.kt": "
|
|
161
|
+
"runtime/LawSpecKotlinCodecs.kt": "811accd1cac055d46f7ae0a2aff03602389fbbaaa2eaf778a9dcdd6899b12466",
|
|
153
162
|
"runtime/LawSpecKotlinStrategies.kt": "8ee1edeec1c342f2bc70ca8bdad22ec5aabc38f6f61381fe905b717ffce0688e",
|
|
154
|
-
"runtime/LawSpecRuntime.hs": "
|
|
155
|
-
"runtime/LawSpecRuntime.java": "
|
|
163
|
+
"runtime/LawSpecRuntime.hs": "63b6c7d12271bec263c6095ebc2fe9318799eff4235f3b877f63a967a4b81352",
|
|
164
|
+
"runtime/LawSpecRuntime.java": "c7763b4f2a6060b696f89ff0a932ccc68d5d9af3cbfdc258614c7b90aec4ff8a",
|
|
156
165
|
"runtime/LawSpecSchema.hs": "c19eedd197fc2359780c1576dd6a1d6e9bcdaf2ed037b5dbb37f3db766356bf9",
|
|
157
|
-
"runtime/LawSpecSchema.java": "
|
|
166
|
+
"runtime/LawSpecSchema.java": "bdf02d151db8635956d5d1266ba4434e507aee573eb8659112df010980a8d854",
|
|
158
167
|
"runtime/LawSpecStrategies.kt": "569f7775c0ac44765d05567cbf62d026558ac193c080ca71681ec6ee49c21794",
|
|
159
|
-
"runtime/lawspec_codecs.go": "
|
|
168
|
+
"runtime/lawspec_codecs.go": "57dadec7eb3e9912178b3d6f2e507a42f03f4e81807ffd30385dba446f6ef4dd",
|
|
160
169
|
"runtime/lawspec_data_strategies.go": "65ca2a09012c516c17bb66d7381637e71f454740858f648a78b9e536f1c7c600",
|
|
161
170
|
"runtime/lawspec_data_strategies.mjs": "5fe9327a6dda2e759558b77100aec96798f1aed4f517d4bc91f45a543b8d14b9",
|
|
162
171
|
"runtime/lawspec_data_strategies.py": "0d06f0c5b9cdd5f6659f424a328884b670c94b1572ec0fa5d5408a05110d94dd",
|
|
163
|
-
"runtime/lawspec_runtime.go": "
|
|
164
|
-
"runtime/lawspec_runtime.mjs": "
|
|
165
|
-
"runtime/lawspec_runtime.py": "
|
|
166
|
-
"runtime/lawspec_runtime.rs": "
|
|
172
|
+
"runtime/lawspec_runtime.go": "36f73eedd4ca35e6b7ebb93fd63ac356e8e04366c63c80b42cf72112ec8b8ba8",
|
|
173
|
+
"runtime/lawspec_runtime.mjs": "576389ebdc770bddb4092bb9229a71ce54e37ba8da90ffde8de15305004c0ec8",
|
|
174
|
+
"runtime/lawspec_runtime.py": "93c8b0bf87d9e6af26bb33e4c1d8611927df295e9cab9d11f73872d0f35ccbf6",
|
|
175
|
+
"runtime/lawspec_runtime.rs": "1e9f898325dda99e44f07e7d422e7b234ebae73d7845d98391f8e3d6851c6f0e",
|
|
167
176
|
"runtime/lawspec_schema.go": "7e9361e9693c3885d98500026f3e3ef8e213eb72a489a58fc72669e8a9938103",
|
|
168
177
|
"runtime/lawspec_schema.mjs": "d77abea1a9dcb03e4a6c6eef6509971d8599fac9acdefa9b9e4b89b8d0fc5226",
|
|
169
|
-
"runtime/lawspec_schema.py": "
|
|
170
|
-
"runtime/lawspec_strategies.rs": "
|
|
171
|
-
"runtime/rust/Cargo.lock": "
|
|
172
|
-
"runtime/rust/Cargo.toml": "
|
|
173
|
-
"src/LawSpec/Api.hs": "
|
|
174
|
-
"src/LawSpec/Backend.hs": "
|
|
178
|
+
"runtime/lawspec_schema.py": "dd29fd2624c204442bfd3ed8a420a853413aa520c5d99f4e5028db7ce21e34c8",
|
|
179
|
+
"runtime/lawspec_strategies.rs": "6c21050184ac20b2ad38e99f47b78fb013f1916389e85e522dd73209133af990",
|
|
180
|
+
"runtime/rust/Cargo.lock": "f7200d8d23c2325ba49315e5f03b58957c0a1df6ef9fea3542aa0bd95ed605ee",
|
|
181
|
+
"runtime/rust/Cargo.toml": "e5c2240c00392995e668ce50c26bd1e96cd57719b3769d09bab077519a5cd198",
|
|
182
|
+
"src/LawSpec/Api.hs": "c0cb09ea2754f79138697e6ee6b4817a43d8343cb410380389d6b321c2feb07b",
|
|
183
|
+
"src/LawSpec/Backend.hs": "709581d869bbc3c3103d72b8d4b4d506b96eceefee03add45ca36acd5cedf41c",
|
|
175
184
|
"src/LawSpec/Capabilities.hs": "ab457f3da440a237ee731d664b94d95a0cc1fa4d8be4d4d0403a61ebcf98e310",
|
|
176
185
|
"src/LawSpec/Code/Doc.hs": "9e3b70f85deb1dcbce385af1d0cd4bea2dfa8a2d806d54745d4bb437406673e5",
|
|
177
186
|
"src/LawSpec/Code/JavaScript.hs": "77bf27dcc210216e4739f68c4709f556f80130ab83b3b9387ac4a2421e790910",
|
|
178
|
-
"src/LawSpec/Collections.hs": "
|
|
187
|
+
"src/LawSpec/Collections.hs": "0635f3164c8d234956b7d47c7da3d2ab7a857e3d7eca55873777cf4492356f95",
|
|
179
188
|
"src/LawSpec/Common.hs": "107612a8aaa787488413acf9c1a56622004d3bff251db89b99928343e6070883",
|
|
180
|
-
"src/LawSpec/Compile.hs": "
|
|
181
|
-
"src/LawSpec/Core.hs": "
|
|
189
|
+
"src/LawSpec/Compile.hs": "efca518b2f0a7dff48927dedc3d6752e10228520d1cae4567aabc2bfac3d94a1",
|
|
190
|
+
"src/LawSpec/Core.hs": "3584b20ad29ba9a939c6ba8967757f4cb49078e325bec7acdf4b2e00cdde3bb2",
|
|
182
191
|
"src/LawSpec/Core/DefinitionContracts.hs": "b7f60f038b231187ecf898e585ae1a8fb1fc113bb55bad6d1bb2660350fd969e",
|
|
183
|
-
"src/LawSpec/Core/Definitions.hs": "
|
|
184
|
-
"src/LawSpec/Core/Eval.hs": "
|
|
192
|
+
"src/LawSpec/Core/Definitions.hs": "a57e30f6864a6bae7e60cd08ef968b1adc9bbd1c86d4b20c405276eccd604f8d",
|
|
193
|
+
"src/LawSpec/Core/Eval.hs": "7c55598054f76e5f3c332a53df46bc2090a4914e8e1460671896f50db0102a9d",
|
|
185
194
|
"src/LawSpec/Core/Evidence.hs": "48442ab98eafaa0f09d56c01493b73b724845347bbd27ae390c64366faec938d",
|
|
186
|
-
"src/LawSpec/Core/Expression.hs": "
|
|
195
|
+
"src/LawSpec/Core/Expression.hs": "850ff201b56553021404ed783e037f9a27a7d70658c62f5e22e89868bb06044a",
|
|
187
196
|
"src/LawSpec/Core/Payload.hs": "da2417fc99354338eab49a688c5f36cecde5ec1aacd8582c895428568b10a376",
|
|
188
197
|
"src/LawSpec/Core/PayloadPlan.hs": "f2a7d2dc58c6a0f79707bdc24773bd3aad3a3b8eea2735a8284b2a9f3a4af4a8",
|
|
198
|
+
"src/LawSpec/Core/Policy.hs": "c0fdb7babe904bafa0fe97c2089f63ae393c3e8845a6d3110e12d8531e0656f0",
|
|
189
199
|
"src/LawSpec/Core/RefinementProof.hs": "c19fc03e68488357a59897ec38ce3d2efd320c35b405b632af17425d6a18447a",
|
|
190
200
|
"src/LawSpec/Core/Schema.hs": "ce06bd96b63d11f80be518e626b33526668ae1e2f3f7fc626bb1048e296efc21",
|
|
191
201
|
"src/LawSpec/Core/Semantics.hs": "cdb8256e523f7808fa50fe7d80d709217a28de4c81c5ff5be8382f94900f3779",
|
|
192
|
-
"src/LawSpec/Core/
|
|
193
|
-
"src/LawSpec/Core/
|
|
202
|
+
"src/LawSpec/Core/Stages.hs": "b88b974e3510ca797bd4ad8a22c47d63cce28245fc4775999d666e8f2d8dac56",
|
|
203
|
+
"src/LawSpec/Core/Total.hs": "d706a145c3663b6bd3f0ecf390fee1fe4847564ec4f9ce70fa7583ead04a933a",
|
|
204
|
+
"src/LawSpec/Core/Totality.hs": "a9460bc11a91be583274bf4e87bbc85630a544736c4d532a61cf9038f1a3d42d",
|
|
194
205
|
"src/LawSpec/Core/Types.hs": "04d9c093fcc0d84e2864c8a3b69d5fe318a92c60b32844048198f1b12fe1b6fb",
|
|
195
206
|
"src/LawSpec/Core/Validate.hs": "74c2a51eb913f8414268064f22d2d5d97ebfb0e4797e146b229076c29ac38726",
|
|
196
|
-
"src/LawSpec/Core/Value.hs": "
|
|
197
|
-
"src/LawSpec/CoreEmit.hs": "
|
|
198
|
-
"src/LawSpec/CoreNativeScalarEmit.hs": "
|
|
199
|
-
"src/LawSpec/
|
|
207
|
+
"src/LawSpec/Core/Value.hs": "52fedabbc07c8c65acc5be1efc7b4860bee47b58931ef76d26fcbfc8a280bf41",
|
|
208
|
+
"src/LawSpec/CoreEmit.hs": "6af51e63da17000b0bab20e0cc9a74dab93d02209c14e564bda024262e5887e4",
|
|
209
|
+
"src/LawSpec/CoreNativeScalarEmit.hs": "7c35c0405717f6cbf9dd0cbecb430678fda9fa95cd6c1363cceade2f1d6ea682",
|
|
210
|
+
"src/LawSpec/CorePersist.hs": "f18f6ae69ff8caa3f5d166f5b64f06716bc4755a7b825a370e233ba90f4b5bb5",
|
|
211
|
+
"src/LawSpec/CoreScalarEmit.hs": "7852454ec42777a5ad1246ba179aa8591f3145a45b8d3cbfb4c4b087a7601243",
|
|
200
212
|
"src/LawSpec/Data.hs": "f659f4e86f1009c4806334a45686970dde2efa2641585f997a7beba01d0e6f2d",
|
|
201
213
|
"src/LawSpec/DataNames.hs": "2eeb0d215131981a2271725a50c21dce44c7146a167025eb239a83922fdecaf6",
|
|
202
|
-
"src/LawSpec/DefinitionTotality.hs": "
|
|
203
|
-
"src/LawSpec/Dependencies.hs": "
|
|
214
|
+
"src/LawSpec/DefinitionTotality.hs": "af3aa9f7495344ea34c90cf87664f3ec2d9f95474ef273905fc6c9b17edd5d80",
|
|
215
|
+
"src/LawSpec/Dependencies.hs": "b748d2231f543a878e2ff3816f8a027285c610555821856383e8d1853e4c7151",
|
|
204
216
|
"src/LawSpec/Digest.hs": "ba8128e36856d5fb0d2345779fd949b11042af688a0d8cee63e5ae8818cef7ca",
|
|
205
|
-
"src/LawSpec/Discharge.hs": "
|
|
217
|
+
"src/LawSpec/Discharge.hs": "26b74132dfb0545dd48baf35c75aba261be109edea0693e2c9ff580750483f88",
|
|
206
218
|
"src/LawSpec/Domain.hs": "222d15f0012ae630802238a6d7e1ee78d1e718b599f5ebb5a1ddc4e8d29d68c3",
|
|
207
|
-
"src/LawSpec/DomainModel.hs": "
|
|
208
|
-
"src/LawSpec/Elaboration.hs": "
|
|
219
|
+
"src/LawSpec/DomainModel.hs": "b2ac0eb9b63fae2860d9f53e6770d8fdf053d9df33773071b31de53cdf4e1562",
|
|
220
|
+
"src/LawSpec/Elaboration.hs": "b6c92cd113c61724b51baf73f94ae9507ff9be8661d0ec16215b8f3399f10f5f",
|
|
209
221
|
"src/LawSpec/Emit.hs": "9f34f5765915a2a12a66a6dca647ddaef9289372956802c6d99cf0cfec447c7a",
|
|
210
222
|
"src/LawSpec/Eval.hs": "b87a786ed7a512c60e00a037a1a36738933518aafa255babaa8b1b42dbb8ff6d",
|
|
211
223
|
"src/LawSpec/Flow.hs": "830b9d59b94f26a05687bd5baed06b4ecbf1f47c6a634766810d3dd2a44647cd",
|
|
212
|
-
"src/LawSpec/Frontend.hs": "
|
|
213
|
-
"src/LawSpec/GoData.hs": "
|
|
214
|
-
"src/LawSpec/GoDefinitions.hs": "
|
|
224
|
+
"src/LawSpec/Frontend.hs": "85d631cb6246efcb14814177d1620ffd5f67964de725a8af241a11f1f30f5da3",
|
|
225
|
+
"src/LawSpec/GoData.hs": "5db907554f6d3d4bbb7e0617214be0260434ac8fb02d49e677325c4154bfee04",
|
|
226
|
+
"src/LawSpec/GoDefinitions.hs": "602977adc5d3bc9c6076bcc98c2e8955eba56ec4b8891534b01f49b7d7bb3206",
|
|
215
227
|
"src/LawSpec/GoExpr.hs": "67ef004e97074976e0fd137dfef8d417efe8de3f7d5c3c08293874d30d89e9d0",
|
|
216
228
|
"src/LawSpec/GoNativeBinding.hs": "1ad8ea4cec6187c7e6005651c0edeec69e196eb329fb958c833da7751225aa1b",
|
|
217
|
-
"src/LawSpec/GoProperties.hs": "
|
|
229
|
+
"src/LawSpec/GoProperties.hs": "3c9f73b42c1e13f86cc0592998090dd5619d55b56d190a05ca1de5d661e87ffa",
|
|
218
230
|
"src/LawSpec/GoTestHelpers.hs": "dee55ee8505370e932773b8c685f4a1f380129e6f43f8806bf1e82efb99451b1",
|
|
219
231
|
"src/LawSpec/GoTypeRefs.hs": "7f239f5ac3ac8bd21c8f76c328049f7715d8562ee1382befa0a58abd4f15f726",
|
|
220
232
|
"src/LawSpec/HaskellData.hs": "8ca1f1a353972a28b3d044c3763243cd8a2abf3e2cdb3b15b6112d8a7edf9da2",
|
|
221
|
-
"src/LawSpec/HaskellDefinitions.hs": "
|
|
233
|
+
"src/LawSpec/HaskellDefinitions.hs": "fe989b62cb970bf4a3060a5793ff11ee5756cdec4c8c97de17f54181ef0112be",
|
|
222
234
|
"src/LawSpec/HaskellExpr.hs": "f7ef064ac6700c027de4bd71bddeb3236853232cf7a39bed61de16153539b401",
|
|
223
235
|
"src/LawSpec/HaskellNativeBinding.hs": "9f98aa0c8659b572bd6486a0e29c4692bc6432db8639fa74a09bbf1b771bbfa6",
|
|
224
|
-
"src/LawSpec/HaskellProperties.hs": "
|
|
236
|
+
"src/LawSpec/HaskellProperties.hs": "9eac50a0c24398a71823c71c75a29cf2718ff53f63890bf764735078f39b2f8a",
|
|
225
237
|
"src/LawSpec/HaskellTestHelpers.hs": "51e59b2abc9e85455e3c8e2c6baadb27e5d319081cb730d2ce56be5dc8053897",
|
|
226
238
|
"src/LawSpec/HaskellTypeRefs.hs": "2225b2a5e2ab3662e7202d23b24f4d6db48353b35ae28df8acd2b92fd2b97574",
|
|
227
|
-
"src/LawSpec/Imports.hs": "
|
|
228
|
-
"src/LawSpec/IndexTerm.hs": "
|
|
239
|
+
"src/LawSpec/Imports.hs": "0f81acb1e85d23b0c5745aa8530b0b979d739f201fc1d3d8f2d901c16c820b4a",
|
|
240
|
+
"src/LawSpec/IndexTerm.hs": "1c694f279b934e7b853c0028158c2754048928deb45fb7d65abc1d98da382bcb",
|
|
229
241
|
"src/LawSpec/Indexed.hs": "1e7ed53653cabc097f75dcf350c81facf9feb30af73f3e21f9344665fc316387",
|
|
230
|
-
"src/LawSpec/Inference.hs": "
|
|
231
|
-
"src/LawSpec/JavaData.hs": "
|
|
232
|
-
"src/LawSpec/JavaDefinitions.hs": "
|
|
242
|
+
"src/LawSpec/Inference.hs": "40693bcf11935f812bac171e981476acd978a16d126855c9ddf385a8b1cc23c3",
|
|
243
|
+
"src/LawSpec/JavaData.hs": "078594c2a233824ff1d1a9c3fbc246e9d77ce4cc724ef1f72ad3aace68be5a93",
|
|
244
|
+
"src/LawSpec/JavaDefinitions.hs": "5247258db6ddb7075e5d05c6bb830aad6e0d9d3314082d164b1b2f5506337476",
|
|
233
245
|
"src/LawSpec/JavaExpr.hs": "fb1d3e64f3288e557720dead7738eb4f2a59d4563e5be4a742e1582829f19d3e",
|
|
234
246
|
"src/LawSpec/JavaNativeBinding.hs": "9eb52b3be19badda078069bb3d6813d72cad4f0a9bfa708f7404e44201d3c352",
|
|
235
|
-
"src/LawSpec/JavaProperties.hs": "
|
|
247
|
+
"src/LawSpec/JavaProperties.hs": "16b334f98eec4c029e630ce31fe7635f6d8d73bfcfb13707e0d348b2cbf23f95",
|
|
236
248
|
"src/LawSpec/JavaTestHelpers.hs": "e6f4b9bbb7e5f07ece6ab1845e12aa661e62e8b926680b11454223fc3ec1523d",
|
|
237
|
-
"src/LawSpec/KotlinData.hs": "
|
|
238
|
-
"src/LawSpec/KotlinDefinitions.hs": "
|
|
249
|
+
"src/LawSpec/KotlinData.hs": "2cd47e1746fb840cc9dc62e02961bbb3a10b982b1b46f89be6816b45282476a3",
|
|
250
|
+
"src/LawSpec/KotlinDefinitions.hs": "4d49a62a1f8ea31a31dc79a6f4aba318f2f71552c495a67499f3cec6dc17fa60",
|
|
239
251
|
"src/LawSpec/KotlinExpr.hs": "20312f0774f1d0832a21a19b93c8103e2791ecd32a827d8e9c4f2b4830a996a0",
|
|
240
252
|
"src/LawSpec/KotlinNativeBinding.hs": "1aec7854758f07a4d2288de13931fbb88ef32220f85d3c84fe8233ad67b6d095",
|
|
241
|
-
"src/LawSpec/KotlinProperties.hs": "
|
|
253
|
+
"src/LawSpec/KotlinProperties.hs": "59ac7374bb2184cb41458ce2d8d5170adc67d913ac87a18c4c69174ee9d941a7",
|
|
242
254
|
"src/LawSpec/KotlinTestHelpers.hs": "74810d65faafc6ed4d64b1fb0596cda4186e586b7144a7441641b798795bc324",
|
|
243
|
-
"src/LawSpec/Memo.hs": "
|
|
244
|
-
"src/LawSpec/Model.hs": "
|
|
255
|
+
"src/LawSpec/Memo.hs": "1230a08b003cc6eee0db951b55a93f9ec573e5b6752c63d65d6c3487927b0b4e",
|
|
256
|
+
"src/LawSpec/Model.hs": "6b3e70ba85a1613c969567a7a6d5ad75126e3df6cbc51a80eb964424f1bff4d6",
|
|
245
257
|
"src/LawSpec/NativeBinding.hs": "33959b0fd432ad4150f3b685f6438e284b801c2a59d9ef3132486a1cc7c8925a",
|
|
246
258
|
"src/LawSpec/NativeRequest.hs": "f8200c36725859ea32374655951f7a45e2b3342b159f9f6c88b5f9a2a6331897",
|
|
247
259
|
"src/LawSpec/Packages.hs": "161fc68a9959a80762ca4ece405240351e3180ea4dbb2bf148eaca6562fb7c30",
|
|
248
|
-
"src/LawSpec/Parser.hs": "
|
|
260
|
+
"src/LawSpec/Parser.hs": "a2b7b241a60395b067690d74dc7385bb9365f10eda08ebb7d4372953b596b624",
|
|
261
|
+
"src/LawSpec/Persist.hs": "d7f63a1205782c2ac0d71b737ade3ef90041403f3876b0f3a38c2b29d60922f2",
|
|
249
262
|
"src/LawSpec/PortableGenerator.hs": "69d457e39f539c77fc7a4c08205e75352bbecd9dfdff031a283a39bf44b22d49",
|
|
250
263
|
"src/LawSpec/PortableTestHelpers.hs": "8d98184c92a34b431f2a820cef3ea735b0cec3a52504f519b3bb06cb5174017c",
|
|
251
|
-
"src/LawSpec/Prelude.hs": "
|
|
264
|
+
"src/LawSpec/Prelude.hs": "515698dda42a8b950c8529b14b5f9d6fe25e590eb1a7a2593ccbcb2edf87ea57",
|
|
252
265
|
"src/LawSpec/Public.hs": "7010357e250607a9f94d1ab8dc34fad4014fb7d9f15ba0d7c2fc94d0f48fcac4",
|
|
253
|
-
"src/LawSpec/PythonData.hs": "
|
|
254
|
-
"src/LawSpec/PythonDefinitions.hs": "
|
|
266
|
+
"src/LawSpec/PythonData.hs": "09fc455151c0c527c53032512515482a970ecf45a1d529581622c47732c4bbb8",
|
|
267
|
+
"src/LawSpec/PythonDefinitions.hs": "72e0ae7154d3d2c4350975477802495061fe8a2bb0dc420a54c2d6cc75c4d1a3",
|
|
255
268
|
"src/LawSpec/PythonExpr.hs": "23d7d24b5fb4efff9cb63d38c02a93d95744ec79b4565daf1412088fc7c4ba59",
|
|
256
269
|
"src/LawSpec/PythonNativeBinding.hs": "4e35ff8781062d0f614e45ea45f98038c8d609ab78bd671cb0a239eaa9db1690",
|
|
257
|
-
"src/LawSpec/PythonTypes.hs": "
|
|
270
|
+
"src/LawSpec/PythonTypes.hs": "bee4b5a5b00ad6ed358cdbcb6de02cd8be9be27e34c1c3ebe3256681aeb1e219",
|
|
271
|
+
"src/LawSpec/Railway.hs": "cada409ef5703cc5626b0ba36ba85f1fcfa6380c4baa9d4942342ea5c20be963",
|
|
258
272
|
"src/LawSpec/Refinement.hs": "3bbdc090f9ebce60d99254dbe93dec6e11bd838df8537df828fd9c768c79d126",
|
|
259
|
-
"src/LawSpec/
|
|
260
|
-
"src/LawSpec/
|
|
261
|
-
"src/LawSpec/
|
|
262
|
-
"src/LawSpec/
|
|
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",
|
|
263
278
|
"src/LawSpec/RustExpr.hs": "04b2ef81417b811c7b98a98acdadab4e588ca8757964a63ba8dc5936c36479e6",
|
|
264
279
|
"src/LawSpec/RustNativeBinding.hs": "d50d1fb10591ee86129ae49b38a343148c084479e450eef3b320e1efdd55245d",
|
|
265
280
|
"src/LawSpec/RustNativeGenerators.hs": "a3b1484d9ff0008e4f961aa81d0aa51da57ec0cd7909124e80c98d56aacc8ce9",
|
|
266
|
-
"src/LawSpec/Scaffold.hs": "
|
|
267
|
-
"src/LawSpec/Scalar.hs": "
|
|
281
|
+
"src/LawSpec/Scaffold.hs": "b4b02a2b565fd5bf3d056c68a24979339b6d4bd0a4182c0dc7b5faf79b8ec273",
|
|
282
|
+
"src/LawSpec/Scalar.hs": "8ff178cbce4aa514f4b770e65efd471461cc12812e854d95f48b0dd54f0cc637",
|
|
268
283
|
"src/LawSpec/SpecializeDefinitions.hs": "2bdd6d9b191941d869ef524659e02fed551499aaa2ea98c99323da03af113012",
|
|
269
|
-
"src/LawSpec/
|
|
284
|
+
"src/LawSpec/TargetNames.hs": "06410a1973d12bc241bfc399c8f5856d1692c6af792bb83b187bca894cfde4ca",
|
|
285
|
+
"src/LawSpec/TestManifest.hs": "3c2018eea1528d047dff4c5fd2f353ee1ceb339cce7b1c32f0a2390df2d40ac8",
|
|
286
|
+
"src/LawSpec/Testing.hs": "3bb83c3e74de6f0a09b12736115e47b4db2244e2f749d640e063cfc0500f174c",
|
|
287
|
+
"src/LawSpec/Time.hs": "9b05a784879a5791087492129bb9bd432d5e23082aa370e2a289552731bfb527",
|
|
270
288
|
"src/LawSpec/WebData.hs": "bbcd7d734ce3941d83cc455a9a2147b642f6111ebb34db9ef99dcb7a58b8c4ae",
|
|
271
|
-
"src/LawSpec/WebDefinitions.hs": "
|
|
272
|
-
"src/LawSpec/WebExpr.hs": "
|
|
289
|
+
"src/LawSpec/WebDefinitions.hs": "896c7b7b3bf69f331fba98d1ee9f9b1bf30af349fc93dfdb490081760106f2fb",
|
|
290
|
+
"src/LawSpec/WebExpr.hs": "5bf5a2082f216646541bfa482f0f4eb492e32da9ab965e1e789256564d64332f",
|
|
273
291
|
"src/LawSpec/WebNativeBinding.hs": "f536c1b1454bc83f5a9e8c61a608390b9a6fa91537f34d3c245b90ee6e275b7d",
|
|
274
292
|
"src/LawSpec/WebTypes.hs": "1d43194e4dafbdcbed6e607414a875e9030028f03579f17d189c14a6a9bd5e53",
|
|
275
293
|
"src/LawSpec/Witness.hs": "9ae944c9307df964bc853205269c1e4cb69cc076070bb878fc957f4bdb02de85",
|
|
@@ -278,10 +296,10 @@
|
|
|
278
296
|
"wasm/app/Exports.hs": "4ecbdac8faa2449e6fc61b93c82e6278fa14374154f29b4dacf0eef433f06a47",
|
|
279
297
|
"wasm/cabal.project": "021e560afdc5eb4cb7169e7119ecb8f92c9ee170245af909c94b612941bff5cc",
|
|
280
298
|
"wasm/cabal.project.freeze": "733dbed3d2ecccb26e874fd58f136296dad772184deb1658c196b5d54a0814dc",
|
|
281
|
-
"wasm/lawspec-wasm.cabal": "
|
|
282
|
-
"npm/core.wasm": "
|
|
299
|
+
"wasm/lawspec-wasm.cabal": "36699a4aca6e7ad1c8ab81160ee5f8238e826fd977db5ca6e10b6c806786cbcb",
|
|
300
|
+
"npm/core.wasm": "7409a9cdb0da8e65445f2451c115248798f972853a81132848a63253a246341e",
|
|
283
301
|
"npm/core_jsffi.js": "88d136efe92f7cff5758c8fec8d9b6bbc9707fe37741cebeeb415fe34ce3d72b",
|
|
284
302
|
"npm/api.mjs": "19e1624f91258c1397f3212faf65b407c62671b0fc5b118520e6a91f7ad7c6ba",
|
|
285
|
-
"npm/index.d.ts": "
|
|
303
|
+
"npm/index.d.ts": "b6beef671c22633fdf369f584bfe9bc9bd0b281c54df06f1946970415e1e7793"
|
|
286
304
|
}
|
|
287
305
|
}
|
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
|
|
18
|
-
--
|
|
19
|
-
--
|
|
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
|