lawspec 0.25.0 → 0.27.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.
Files changed (156) hide show
  1. package/CHANGELOG.md +109 -1
  2. package/NORMALIZATION-LICENSES.txt +296 -0
  3. package/README.md +13 -4
  4. package/api.mjs +0 -8
  5. package/bin/lawspec.mjs +114 -79
  6. package/build.json +99 -117
  7. package/core.wasm +2 -2
  8. package/core_jsffi.js +5 -0
  9. package/doctor.mjs +14 -4
  10. package/examples/native-payments/clojure/lawspec.json +1 -1
  11. package/examples/native-payments/csharp/lawspec.json +1 -1
  12. package/examples/native-payments/elixir/lawspec.json +1 -1
  13. package/examples/native-payments/erlang/lawspec.json +1 -1
  14. package/examples/native-payments/fsharp/lawspec.json +1 -1
  15. package/examples/native-payments/gleam/lawspec.json +1 -1
  16. package/examples/native-payments/go/lawspec.json +1 -1
  17. package/examples/native-payments/groovy/lawspec.json +1 -1
  18. package/examples/native-payments/haskell/lawspec.json +1 -1
  19. package/examples/native-payments/java/lawspec.json +1 -1
  20. package/examples/native-payments/javascript/lawspec.json +1 -1
  21. package/examples/native-payments/kotlin/lawspec.json +1 -1
  22. package/examples/native-payments/prolog/lawspec.json +20 -0
  23. package/examples/native-payments/prolog/src/domain/payments.pl +23 -0
  24. package/examples/native-payments/prolog/tests/domain/payment_generators.pl +17 -0
  25. package/examples/native-payments/python/lawspec.json +1 -1
  26. package/examples/native-payments/rust/lawspec.json +1 -1
  27. package/examples/native-payments/scala/lawspec.json +1 -1
  28. package/examples/native-payments/swift/lawspec.json +1 -1
  29. package/examples/native-payments/typescript/lawspec.json +1 -1
  30. package/examples/packages/orders/lawspec.json +1 -1
  31. package/examples/packages/orders/orders.lawspec +27 -25
  32. package/examples/packages/shop-domain/src/domain.lawspec +15 -14
  33. package/examples/packages/shop-tax-1/src/api.lawspec +1 -0
  34. package/examples/packages/shop-tax-1/src/rates.lawspec +1 -0
  35. package/examples/packages/shop-tax-2/src/api.lawspec +1 -0
  36. package/examples/packages/shop-tax-2/src/rates.lawspec +1 -0
  37. package/examples/rc1/authorization-snapshots.lawspec +24 -23
  38. package/examples/rc1/banner-filenames.lawspec +7 -6
  39. package/examples/rc1/bit-codec.lawspec +12 -11
  40. package/examples/rc1/bounded-witness-search.lawspec +52 -45
  41. package/examples/rc1/conflicting-requirements.lawspec +8 -7
  42. package/examples/rc1/constructive-witnesses.lawspec +40 -33
  43. package/examples/rc1/documentary-review.lawspec +9 -8
  44. package/examples/rc1/empty-domains.lawspec +16 -15
  45. package/examples/rc1/finite-integer-domains.lawspec +24 -23
  46. package/examples/rc1/law-metadata.lawspec +6 -5
  47. package/examples/rc1/native-payments.lawspec +17 -16
  48. package/examples/rc1/nesting/rrr.lawspec +4 -3
  49. package/examples/rc1/nesting/rru.lawspec +7 -6
  50. package/examples/rc1/nesting/rur.lawspec +7 -6
  51. package/examples/rc1/nesting/ruu.lawspec +10 -9
  52. package/examples/rc1/nesting/urr.lawspec +7 -6
  53. package/examples/rc1/nesting/uru.lawspec +10 -9
  54. package/examples/rc1/nesting/uur.lawspec +10 -9
  55. package/examples/rc1/nesting/uuu.lawspec +13 -12
  56. package/examples/rc1/order-workflow.lawspec +18 -17
  57. package/examples/rc1/parcel-measurements.lawspec +14 -13
  58. package/examples/rc1/picture-records.lawspec +6 -5
  59. package/examples/rc1/picture-tuples.lawspec +6 -5
  60. package/examples/rc1/record-payloads.lawspec +12 -11
  61. package/examples/rc1/recursive-records.lawspec +11 -10
  62. package/examples/rc1/refund-conformance.lawspec +7 -6
  63. package/examples/rc1/refund-policy.lawspec +15 -14
  64. package/examples/rc1/requirement-composition.lawspec +26 -25
  65. package/examples/rc1/structural-records.lawspec +13 -12
  66. package/examples/rc1-authoring.lawspec +6 -5
  67. package/examples/specs/abilities.lawspec +67 -65
  68. package/examples/specs/ability_imports.lawspec +58 -57
  69. package/examples/specs/actors.lawspec +23 -22
  70. package/examples/specs/algebra.lawspec +142 -141
  71. package/examples/specs/approvals.lawspec +19 -18
  72. package/examples/specs/async_bindings.lawspec +10 -9
  73. package/examples/specs/async_fetch.lawspec +12 -11
  74. package/examples/specs/atoi_codec.lawspec +16 -15
  75. package/examples/specs/boolean_flags.lawspec +10 -9
  76. package/examples/specs/builtins.lawspec +73 -72
  77. package/examples/specs/canonical_url.lawspec +14 -13
  78. package/examples/specs/collections.lawspec +153 -154
  79. package/examples/specs/composition.lawspec +70 -66
  80. package/examples/specs/concurrent_collections.lawspec +8 -7
  81. package/examples/specs/consistency.lawspec +4 -3
  82. package/examples/specs/contracts.lawspec +80 -79
  83. package/examples/specs/crypto.lawspec +26 -25
  84. package/examples/specs/ctc.lawspec +148 -0
  85. package/examples/specs/currying.lawspec +32 -31
  86. package/examples/specs/data_types.lawspec +50 -49
  87. package/examples/specs/distribution.lawspec +57 -56
  88. package/examples/specs/domain_modeling.lawspec +68 -47
  89. package/examples/specs/durations.lawspec +39 -38
  90. package/examples/specs/equivalent.lawspec +25 -24
  91. package/examples/specs/failures.lawspec +64 -63
  92. package/examples/specs/finite_data.lawspec +32 -31
  93. package/examples/specs/flow_stack.lawspec +64 -63
  94. package/examples/specs/gadt_expressions.lawspec +50 -49
  95. package/examples/specs/generation.lawspec +115 -114
  96. package/examples/specs/handler_bindings.lawspec +42 -40
  97. package/examples/specs/handles.lawspec +2 -1
  98. package/examples/specs/harness.lawspec +45 -43
  99. package/examples/specs/harness_testing.lawspec +18 -13
  100. package/examples/specs/indexed_arithmetic.lawspec +401 -126
  101. package/examples/specs/indexed_families.lawspec +182 -66
  102. package/examples/specs/keywords.lawspec +22 -21
  103. package/examples/specs/limits.lawspec +7 -6
  104. package/examples/specs/list_contracts.lawspec +121 -120
  105. package/examples/specs/list_refinements.lawspec +43 -42
  106. package/examples/specs/lists.lawspec +45 -44
  107. package/examples/specs/matchers.lawspec +79 -78
  108. package/examples/specs/matching.lawspec +43 -42
  109. package/examples/specs/mixed_inputs.lawspec +25 -24
  110. package/examples/specs/models.lawspec +44 -43
  111. package/examples/specs/parse_port.lawspec +28 -27
  112. package/examples/specs/payments.lawspec +55 -54
  113. package/examples/specs/railway.lawspec +59 -58
  114. package/examples/specs/records.lawspec +149 -148
  115. package/examples/specs/records_inner.lawspec +5 -4
  116. package/examples/specs/recursive_refinements.lawspec +30 -29
  117. package/examples/specs/refined_definitions.lawspec +24 -23
  118. package/examples/specs/refinements.lawspec +58 -57
  119. package/examples/specs/resilience.lawspec +161 -160
  120. package/examples/specs/resources.lawspec +61 -60
  121. package/examples/specs/scalar_adapters.lawspec +60 -59
  122. package/examples/specs/scalar_catalog.lawspec +165 -164
  123. package/examples/specs/scalars.lawspec +78 -77
  124. package/examples/specs/scheduling_order.lawspec +8 -7
  125. package/examples/specs/scheduling_overlap.lawspec +5 -4
  126. package/examples/specs/sequences.lawspec +66 -65
  127. package/examples/specs/sessions.lawspec +13 -12
  128. package/examples/specs/slug.lawspec +16 -15
  129. package/examples/specs/sum_refinements.lawspec +42 -41
  130. package/examples/specs/tables.lawspec +29 -28
  131. package/examples/specs/total_functions.lawspec +71 -70
  132. package/examples/specs/workflows.lawspec +101 -100
  133. package/examples-command.mjs +7 -7
  134. package/explain.mjs +6 -4
  135. package/expression-presentation.mjs +8 -8
  136. package/files.mjs +1 -1
  137. package/index.d.ts +10 -528
  138. package/launcher.mjs +9 -2
  139. package/lsp.mjs +10 -6
  140. package/native-evidence.mjs +25 -12
  141. package/native-examples.mjs +3 -3
  142. package/package.json +2 -1
  143. package/starter-rc1.lawspec +6 -5
  144. package/starter.lawspec +16 -15
  145. package/templates.mjs +88 -5
  146. package/test-command.mjs +40 -4
  147. package/migrate.mjs +0 -135
  148. package/migration-bindings.mjs +0 -86
  149. package/migration-cases.mjs +0 -45
  150. package/migration-collections.mjs +0 -54
  151. package/migration-correspondence.mjs +0 -275
  152. package/migration-generation.mjs +0 -99
  153. package/migration-laws.mjs +0 -102
  154. package/migration-records.mjs +0 -166
  155. package/migration-source.mjs +0 -247
  156. package/migration-write.mjs +0 -156
@@ -9,157 +9,157 @@ subtractValue :: Integer -> Integer -> Integer
9
9
  divideLeft :: Integer -> Integer -> Integer
10
10
  divideRight :: Integer -> Integer -> Integer
11
11
 
12
- law `addition is commutative` is
13
- definition is
14
- `commutative` add
15
- end
12
+ law "|addition is commutative| is
13
+ definition :
14
+ apply law "|commutative| add
15
+ end definition
16
16
 
17
- example `3 plus 5 and 5 plus 3 both produce 8` is
17
+ example "|3 plus 5 and 5 plus 3 both produce 8| :
18
18
  x = 3
19
19
  y = 5
20
20
  expect add x y = 8
21
21
  expect add y x = 8
22
- end
22
+ end example
23
23
 
24
- example `addition exceeds the Int32 maximum without wrapping` is
24
+ example "|addition exceeds the Int32 maximum without wrapping| :
25
25
  x = 2147483647
26
26
  y = 1
27
27
  expect add x y = 2147483648
28
28
  expect add y x = 2147483648
29
- end
29
+ end example
30
30
 
31
- example `addition remains exact beyond machine and safe-number bounds` is
31
+ example "|addition remains exact beyond machine and safe-number bounds| :
32
32
  x = 18446744073709551615
33
33
  y = 2
34
34
  expect add x y = 18446744073709551617
35
35
  expect add y x = 18446744073709551617
36
- end
37
- end
36
+ end example
37
+ end law
38
38
 
39
- law `addition is associative` is
40
- definition is
41
- `associative` add
42
- end
39
+ law "|addition is associative| is
40
+ definition :
41
+ apply law "|associative| add
42
+ end definition
43
43
 
44
- example `both groupings of 3 plus 5 plus 7 produce 15` is
44
+ example "|both groupings of 3 plus 5 plus 7 produce 15| :
45
45
  x = 3
46
46
  y = 5
47
47
  z = 7
48
48
  expect add (add x y) z = 15
49
49
  expect add x (add y z) = 15
50
- end
51
- end
50
+ end example
51
+ end law
52
52
 
53
- law `zero is left identity for addition` is
54
- definition is
55
- `left identity` add 0
56
- end
53
+ law "|zero is left identity for addition| is
54
+ definition :
55
+ apply law "|left identity| add 0
56
+ end definition
57
57
 
58
- example `adding zero on left preserves 3` is
58
+ example "|adding zero on left preserves 3| :
59
59
  x = 3
60
60
  expect add 0 x = 3
61
- end
62
- end
61
+ end example
62
+ end law
63
63
 
64
- law `zero is right identity for addition` is
65
- definition is
66
- `right identity` add 0
67
- end
64
+ law "|zero is right identity for addition| is
65
+ definition :
66
+ apply law "|right identity| add 0
67
+ end definition
68
68
 
69
- example `adding zero on right preserves 3` is
69
+ example "|adding zero on right preserves 3| :
70
70
  x = 3
71
71
  expect add x 0 = 3
72
- end
73
- end
72
+ end example
73
+ end law
74
74
 
75
- law `zero is two-sided identity for addition` is
76
- definition is
77
- `identity` add 0
78
- end
75
+ law "|zero is two-sided identity for addition| is
76
+ definition :
77
+ apply law "|identity| add 0
78
+ end definition
79
79
 
80
- example `adding zero on both sides preserves 3` is
80
+ example "|adding zero on both sides preserves 3| :
81
81
  x = 3
82
82
  expect add 0 x = 3
83
83
  expect add x 0 = 3
84
- end
85
- end
84
+ end example
85
+ end law
86
86
 
87
- law `zero absorbs multiplication left` is
88
- definition is
89
- `left absorbing element` multiply 0
90
- end
87
+ law "|zero absorbs multiplication left| is
88
+ definition :
89
+ apply law "|left absorbing element| multiply 0
90
+ end definition
91
91
 
92
- example `zero on left of multiplication produces zero` is
92
+ example "|zero on left of multiplication produces zero| :
93
93
  x = 3
94
94
  expect multiply 0 x = 0
95
- end
96
- end
95
+ end example
96
+ end law
97
97
 
98
- law `zero absorbs multiplication right` is
99
- definition is
100
- `right absorbing element` multiply 0
101
- end
98
+ law "|zero absorbs multiplication right| is
99
+ definition :
100
+ apply law "|right absorbing element| multiply 0
101
+ end definition
102
102
 
103
- example `zero on right of multiplication produces zero` is
103
+ example "|zero on right of multiplication produces zero| :
104
104
  x = 3
105
105
  expect multiply x 0 = 0
106
- end
107
- end
106
+ end example
107
+ end law
108
108
 
109
- law `zero absorbs multiplication on both sides` is
110
- definition is
111
- `absorbing element` multiply 0
112
- end
109
+ law "|zero absorbs multiplication on both sides| is
110
+ definition :
111
+ apply law "|absorbing element| multiply 0
112
+ end definition
113
113
 
114
- example `zero on both sides of multiplication produces zero` is
114
+ example "|zero on both sides of multiplication produces zero| :
115
115
  x = 3
116
116
  expect multiply 0 x = 0
117
117
  expect multiply x 0 = 0
118
- end
119
- end
118
+ end example
119
+ end law
120
120
 
121
- law `multiplication distributes over addition left` is
122
- definition is
123
- `left distributive` multiply add
124
- end
121
+ law "|multiplication distributes over addition left| is
122
+ definition :
123
+ apply law "|left distributive| multiply add
124
+ end definition
125
125
 
126
- example `left distribution produces 36` is
126
+ example "|left distribution produces 36| :
127
127
  x = 3
128
128
  y = 5
129
129
  z = 7
130
130
  expect multiply x (add y z) = 36
131
131
  expect add (multiply x y) (multiply x z) = 36
132
- end
132
+ end example
133
133
 
134
- example `multiplication preserves products outside Int32` is
134
+ example "|multiplication preserves products outside Int32| :
135
135
  x = 2147483647
136
136
  y = 2147483647
137
137
  z = 1
138
138
  expect multiply x y = 4611686014132420609
139
139
  expect multiply x (add y z) = 4611686016279904256
140
- end
141
- end
140
+ end example
141
+ end law
142
142
 
143
- law `multiplication distributes over addition right` is
144
- definition is
145
- `right distributive` multiply add
146
- end
143
+ law "|multiplication distributes over addition right| is
144
+ definition :
145
+ apply law "|right distributive| multiply add
146
+ end definition
147
147
 
148
- example `right distribution produces 56` is
148
+ example "|right distribution produces 56| :
149
149
  x = 3
150
150
  y = 5
151
151
  z = 7
152
152
  expect multiply (add x y) z = 56
153
153
  expect add (multiply x z) (multiply y z) = 56
154
- end
155
- end
154
+ end example
155
+ end law
156
156
 
157
- law `multiplication distributes over addition on both sides` is
158
- definition is
159
- `distributive` multiply add
160
- end
157
+ law "|multiplication distributes over addition on both sides| is
158
+ definition :
159
+ apply law "|distributive| multiply add
160
+ end definition
161
161
 
162
- example `left distribution produces 36; right distribution produces 56` is
162
+ example "|left distribution produces 36; right distribution produces 56| :
163
163
  x = 3
164
164
  y = 5
165
165
  z = 7
@@ -167,91 +167,91 @@ law `multiplication distributes over addition on both sides` is
167
167
  expect add (multiply x y) (multiply x z) = 36
168
168
  expect multiply (add x y) z = 56
169
169
  expect add (multiply x z) (multiply y z) = 56
170
- end
171
- end
170
+ end example
171
+ end law
172
172
 
173
- law `maximum is an idempotent operation` is
174
- definition is
175
- `idempotent operation` maximumValue
176
- end
173
+ law "|maximum is an idempotent operation| is
174
+ definition :
175
+ apply law "|idempotent operation| maximumValue
176
+ end definition
177
177
 
178
- example `the maximum of 3 and itself is 3` is
178
+ example "|the maximum of 3 and itself is 3| :
179
179
  x = 3
180
180
  expect maximumValue x x = 3
181
- end
182
- end
181
+ end example
182
+ end law
183
183
 
184
- law `negation supplies left additive inverses` is
185
- definition is
186
- `left inverse element` add negateValue 0
187
- end
184
+ law "|negation supplies left additive inverses| is
185
+ definition :
186
+ apply law "|left inverse element| add negateValue 0
187
+ end definition
188
188
 
189
- example `3 has inverse -3; the left inverse equation produces zero` is
189
+ example "|3 has inverse -3; the left inverse equation produces zero| :
190
190
  x = 3
191
191
  expect negateValue x = -3
192
192
  expect add (negateValue x) x = 0
193
- end
194
- end
193
+ end example
194
+ end law
195
195
 
196
- law `negation supplies right additive inverses` is
197
- definition is
198
- `right inverse element` add negateValue 0
199
- end
196
+ law "|negation supplies right additive inverses| is
197
+ definition :
198
+ apply law "|right inverse element| add negateValue 0
199
+ end definition
200
200
 
201
- example `3 has inverse -3; the right inverse equation produces zero` is
201
+ example "|3 has inverse -3; the right inverse equation produces zero| :
202
202
  x = 3
203
203
  expect negateValue x = -3
204
204
  expect add x (negateValue x) = 0
205
- end
206
- end
205
+ end example
206
+ end law
207
207
 
208
- law `negation supplies both additive inverses` is
209
- definition is
210
- `invertible` add negateValue 0
211
- end
208
+ law "|negation supplies both additive inverses| is
209
+ definition :
210
+ apply law "|invertible| add negateValue 0
211
+ end definition
212
212
 
213
- example `3 has inverse -3; the left and right inverse equation produces zero` is
213
+ example "|3 has inverse -3; the left and right inverse equation produces zero| :
214
214
  x = 3
215
215
  expect negateValue x = -3
216
216
  expect add (negateValue x) x = 0
217
217
  expect add x (negateValue x) = 0
218
- end
219
- end
218
+ end example
219
+ end law
220
220
 
221
- law `subtraction has left division` is
222
- definition is
223
- `left division` subtractValue divideLeft
224
- end
221
+ law "|subtraction has left division| is
222
+ definition :
223
+ apply law "|left division| subtractValue divideLeft
224
+ end definition
225
225
 
226
- example `left solution is -2 since 3 - (-2) = 5; reversing the operation recovers 5` is
226
+ example "|left solution is -2 since 3 - (-2) = 5; reversing the operation recovers 5| :
227
227
  x = 3
228
228
  y = 5
229
229
  expect divideLeft x y = -2
230
230
  expect subtractValue x (divideLeft x y) = 5
231
231
  expect divideLeft x (subtractValue x y) = 5
232
- end
233
- end
232
+ end example
233
+ end law
234
234
 
235
- law `subtraction has right division` is
236
- definition is
237
- `right division` subtractValue divideRight
238
- end
235
+ law "|subtraction has right division| is
236
+ definition :
237
+ apply law "|right division| subtractValue divideRight
238
+ end definition
239
239
 
240
- example `right solution is 8 since 8 - 5 = 3; reversing the operation recovers 3` is
240
+ example "|right solution is 8 since 8 - 5 = 3; reversing the operation recovers 3| :
241
241
  x = 3
242
242
  y = 5
243
243
  expect divideRight x y = 8
244
244
  expect subtractValue (divideRight x y) y = 3
245
245
  expect divideRight (subtractValue x y) y = 3
246
- end
247
- end
246
+ end example
247
+ end law
248
248
 
249
- law `subtraction has divisible` is
250
- definition is
251
- `divisible` subtractValue divideLeft divideRight
252
- end
249
+ law "|subtraction has divisible| is
250
+ definition :
251
+ apply law "|divisible| subtractValue divideLeft divideRight
252
+ end definition
253
253
 
254
- example `left solution is -2; right solution is 8; both recovery directions hold` is
254
+ example "|left solution is -2; right solution is 8; both recovery directions hold| :
255
255
  x = 3
256
256
  y = 5
257
257
  expect divideLeft x y = -2
@@ -260,23 +260,24 @@ law `subtraction has divisible` is
260
260
  expect divideRight x y = 8
261
261
  expect subtractValue (divideRight x y) y = 3
262
262
  expect divideRight (subtractValue x y) y = 3
263
- end
264
- end
263
+ end example
264
+ end law
265
265
 
266
- law `negation is an involution` is
267
- definition is
268
- `involution` negateValue
269
- end
266
+ law "|negation is an involution| is
267
+ definition :
268
+ apply law "|involution| negateValue
269
+ end definition
270
270
 
271
- example `negating -3 twice restores -3` is
271
+ example "|negating -3 twice restores -3| :
272
272
  x = -3
273
273
  expect negateValue x = 3
274
274
  expect negateValue (negateValue x) = -3
275
- end
275
+ end example
276
276
 
277
- example `negating the Int32 minimum produces a positive integer` is
277
+ example "|negating the Int32 minimum produces a positive integer| :
278
278
  x = -2147483648
279
279
  expect negateValue x = 2147483648
280
280
  expect negateValue (negateValue x) = -2147483648
281
- end
282
- end
281
+ end example
282
+ end law
283
+ end unit
@@ -4,32 +4,33 @@ unit example.approvals
4
4
  -- own unit, so the adapters can call the workflow on every target (a Haskell
5
5
  -- workflow imports its steps' module).
6
6
 
7
- -- Approves order n under the real clock: whether it took less than 550ms,
8
- -- which the slow order does only when its checks run at the same time (the
9
- -- longer one, not the two together).
7
+ -- Approves order n under the real clock: whether the slow order's two checks
8
+ -- overlapped in time, which they do only when they run at the same time. Run
9
+ -- one after the other they cannot overlap, however loaded the machine is.
10
10
  async approvedQuickly :: Int64 -> Bool
11
11
 
12
- law `an all group's checks run at the same time` is
13
- definition is
14
- `for all` (n :: Int64) . approvedQuickly n = true
15
- end
16
- example `the slow order` is
12
+ law "|an all group's checks run at the same time| is
13
+ definition :
14
+ for all (n :: Int64) => approvedQuickly n = true end for all
15
+ end definition
16
+ example "|the slow order| :
17
17
  n = -1
18
18
  expect approvedQuickly n = true
19
- end
20
- end
19
+ end example
20
+ end law
21
21
 
22
22
  -- Approves order n: the messages of its failures, as the workflow reports
23
23
  -- them. Order -1's credit check finishes first, but is declared second.
24
24
  async approvalErrors :: Int64 -> List Text
25
25
 
26
- law `failures are reported in declaration order` is
27
- definition is
28
- `for all` (n :: Int64) .
29
- approvalErrors n = prelude.select (n < 0) ["no stock", "no credit"] []
30
- end
31
- example `the slow order` is
26
+ law "|failures are reported in declaration order| is
27
+ definition :
28
+ for all (n :: Int64) =>
29
+ approvalErrors n = prelude.select (n < 0) ["no stock", "no credit"] [] end for all
30
+ end definition
31
+ example "|the slow order| :
32
32
  n = -1
33
33
  expect approvalErrors n = ["no stock", "no credit"]
34
- end
35
- end
34
+ end example
35
+ end law
36
+ end unit
@@ -11,13 +11,13 @@ async priceOf :: Text -> Int32
11
11
  -- The same price, computed by a native synchronous function.
12
12
  quoteOf :: Text -> Int32
13
13
 
14
- law `a looked-up price is the quoted price` is
15
- definition is `for all` (sku :: Text) . priceOf sku = quoteOf sku end
16
- example `a free sample` is
14
+ law "|a looked-up price is the quoted price| is
15
+ definition : for all (sku :: Text) => priceOf sku = quoteOf sku end for all end definition
16
+ example "|a free sample| :
17
17
  sku = "free"
18
18
  expect priceOf sku = 0
19
- end
20
- end
19
+ end example
20
+ end law
21
21
 
22
22
  -- A shelf is a native object; its methods are asynchronous.
23
23
  handle Shelf
@@ -26,14 +26,15 @@ newShelf :: Unit -> Shelf
26
26
  async restock :: Shelf -> (amount :: Int32 where amount >= 0 && amount <= 100) -> Unit
27
27
  async count :: Shelf -> Int64
28
28
 
29
- definition modelRestock (amount :: Int32 where amount >= 0 && amount <= 100) (total :: Int64 where total >= 0 && total <= 1000000) :: Int64 is
29
+ function modelRestock (amount :: Int32 where amount >= 0 && amount <= 100) (total :: Int64 where total >= 0 && total <= 1000000) -> Int64 is
30
30
  total + amount
31
- end
31
+ end function
32
32
 
33
- definition modelCount (total :: Int64) :: Pair Int64 Int64 is Pair total total end
33
+ function modelCount (total :: Int64) -> Pair Int64 Int64 is Pair total total end function
34
34
 
35
35
  model shelf :: shared Shelf by Int64 is
36
36
  start newShelf ~ 0
37
37
  restock ~ modelRestock
38
38
  count ~ modelCount
39
- end
39
+ end model
40
+ end unit
@@ -11,20 +11,21 @@ async stock :: Text -> Int32
11
11
  -- A local quote of the same price.
12
12
  quote :: Text -> Int32
13
13
 
14
- law `prices agree with quotes` is
15
- definition is `for all` (sku :: Text) . price sku = quote sku end
16
- example `a free sample` is
14
+ law "|prices agree with quotes| is
15
+ definition : for all (sku :: Text) => price sku = quote sku end for all end definition
16
+ example "|a free sample| :
17
17
  sku = "free"
18
18
  expect price sku = 0
19
- end
20
- end
19
+ end example
20
+ end law
21
21
 
22
22
  -- Two awaited calls in one clause.
23
- law `stock never lowers a price` is
24
- definition is `for all` (sku :: Text) . price sku + stock sku >= stock sku end
25
- end
23
+ law "|stock never lowers a price| is
24
+ definition : for all (sku :: Text) => price sku + stock sku >= stock sku end for all end definition
25
+ end law
26
26
 
27
27
  -- An awaited call in a guard.
28
- law `stocked products have prices` is
29
- definition is `for all` (sku :: Text) . stock sku > 0 implies price sku >= 0 end
30
- end
28
+ law "|stocked products have prices| is
29
+ definition : for all (sku :: Text) => stock sku > 0 implies price sku >= 0 end for all end definition
30
+ end law
31
+ end unit
@@ -3,33 +3,34 @@ unit example.atoi_codec
3
3
  itoa :: Int32 -> Text
4
4
  atoi :: Text -> Int32
5
5
 
6
- law `itoa and then atoi yields a` is
7
- definition is
8
- `round trip identity is preserved` itoa atoi
9
- end
6
+ law "|itoa and then atoi yields a| is
7
+ definition :
8
+ apply law "|round trip identity is preserved| itoa atoi
9
+ end definition
10
10
 
11
- description is
11
+ description :
12
12
  "converting an Int32 to Text with {itoa} and then back with {atoi} yields the original Int32"
13
- end
13
+ end description
14
14
 
15
- rationale is
15
+ rationale :
16
16
  "representing an Int32 as Text must not change its value"
17
- end
17
+ end rationale
18
18
 
19
- example `negative integers use a minus sign and round-trip unchanged` is
19
+ example "|negative integers use a minus sign and round-trip unchanged| :
20
20
  x = -42
21
21
  expect itoa x = "-42"
22
22
  expect atoi (itoa x) = -42
23
- end
23
+ end example
24
24
 
25
- example `zero renders as 0 and round-trips unchanged` is
25
+ example "|zero renders as 0 and round-trips unchanged| :
26
26
  x = 0
27
27
  expect itoa x = "0"
28
28
  expect atoi (itoa x) = 0
29
- end
29
+ end example
30
30
 
31
- references are
31
+ references :
32
32
  "left inverse"
33
33
  "round-trip property"
34
- end
35
- end
34
+ end references
35
+ end law
36
+ end unit
@@ -2,20 +2,21 @@ unit example.boolean_flags
2
2
 
3
3
  flipFlag :: Bool -> Bool
4
4
 
5
- law `flipping twice restores either flag` is
6
- definition is
7
- `left inverse` flipFlag flipFlag
8
- end
5
+ law "|flipping twice restores either flag| is
6
+ definition :
7
+ apply law "|left inverse| flipFlag flipFlag
8
+ end definition
9
9
 
10
- example `disabled becomes enabled and then disabled again` is
10
+ example "|disabled becomes enabled and then disabled again| :
11
11
  x = false
12
12
  expect flipFlag x = true
13
13
  expect flipFlag (flipFlag x) = false
14
- end
14
+ end example
15
15
 
16
- example `enabled becomes disabled and then enabled again` is
16
+ example "|enabled becomes disabled and then enabled again| :
17
17
  x = true
18
18
  expect flipFlag x = false
19
19
  expect flipFlag (flipFlag x) = true
20
- end
21
- end
20
+ end example
21
+ end law
22
+ end unit