lawspec 0.23.0 → 0.25.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 +167 -1
- package/README.md +29 -22
- package/UNICODE-LICENSE.txt +39 -0
- package/api.mjs +14 -23
- package/bin/lawspec.mjs +200 -67
- package/build.json +381 -155
- package/builtin-data-names.mjs +73 -0
- package/compatibility.json +21 -0
- package/core.wasm +2 -2
- package/doctor.mjs +98 -1
- package/examples/native-payments/clojure/lawspec.json +62 -0
- package/examples/native-payments/clojure/src/domain/payments.clj +11 -0
- package/examples/native-payments/clojure/test/domain/payment_generators.clj +9 -0
- package/examples/native-payments/csharp/lawspec.json +13 -2
- package/examples/native-payments/elixir/lawspec.json +14 -3
- package/examples/native-payments/erlang/lawspec.json +14 -3
- package/examples/native-payments/fsharp/lawspec.json +14 -3
- package/examples/native-payments/gleam/lawspec.json +14 -3
- package/examples/native-payments/go/lawspec.json +14 -3
- package/examples/native-payments/groovy/lawspec.json +176 -0
- package/examples/native-payments/groovy/src/main/groovy/domain/PaymentsDomain.groovy +49 -0
- package/examples/native-payments/groovy/src/test/groovy/domain/PaymentGenerators.groovy +15 -0
- package/examples/native-payments/haskell/lawspec.json +14 -3
- package/examples/native-payments/java/lawspec.json +14 -3
- package/examples/native-payments/javascript/lawspec.json +14 -3
- package/examples/native-payments/kotlin/lawspec.json +14 -3
- package/examples/native-payments/python/lawspec.json +14 -3
- package/examples/native-payments/rust/lawspec.json +14 -3
- package/examples/native-payments/scala/lawspec.json +176 -0
- package/examples/native-payments/scala/src/main/scala/domain/PaymentsDomain.scala +18 -0
- package/examples/native-payments/scala/src/test/scala/domain/PaymentGenerators.scala +8 -0
- package/examples/native-payments/swift/lawspec.json +165 -0
- package/examples/native-payments/swift/src/Native/PaymentsDomain.swift +35 -0
- package/examples/native-payments/swift/tests/Native/PaymentGenerators.swift +12 -0
- package/examples/native-payments/typescript/lawspec.json +14 -3
- package/examples/packages/orders/lawspec.json +25 -5
- package/examples/packages/orders/orders.lawspec +36 -34
- package/examples/packages/shop-domain/src/domain.lawspec +23 -21
- package/examples/packages/shop-tax-1/src/rates.lawspec +4 -4
- package/examples/packages/shop-tax-2/src/rates.lawspec +5 -4
- package/examples/rc1/authorization-snapshots.lawspec +112 -0
- package/examples/rc1/banner-filenames.lawspec +63 -0
- package/examples/rc1/bit-codec.lawspec +56 -0
- package/examples/rc1/bounded-witness-search.lawspec +144 -0
- package/examples/rc1/conflicting-requirements.lawspec +30 -0
- package/examples/rc1/constructive-witnesses.lawspec +113 -0
- package/examples/rc1/documentary-review.lawspec +42 -0
- package/examples/rc1/empty-domains.lawspec +46 -0
- package/examples/rc1/finite-integer-domains.lawspec +75 -0
- package/examples/rc1/law-metadata.lawspec +29 -0
- package/examples/rc1/native-payments.lawspec +107 -0
- package/examples/rc1/nesting/rrr.lawspec +33 -0
- package/examples/rc1/nesting/rru.lawspec +56 -0
- package/examples/rc1/nesting/rur.lawspec +57 -0
- package/examples/rc1/nesting/ruu.lawspec +77 -0
- package/examples/rc1/nesting/urr.lawspec +52 -0
- package/examples/rc1/nesting/uru.lawspec +72 -0
- package/examples/rc1/nesting/uur.lawspec +73 -0
- package/examples/rc1/nesting/uuu.lawspec +95 -0
- package/examples/rc1/order-workflow.lawspec +126 -0
- package/examples/rc1/parcel-measurements.lawspec +92 -0
- package/examples/rc1/picture-records.lawspec +51 -0
- package/examples/rc1/picture-tuples.lawspec +47 -0
- package/examples/rc1/record-payloads.lawspec +56 -0
- package/examples/rc1/recursive-records.lawspec +64 -0
- package/examples/rc1/refund-conformance.lawspec +44 -0
- package/examples/rc1/refund-policy.lawspec +88 -0
- package/examples/rc1/requirement-composition.lawspec +89 -0
- package/examples/rc1/structural-records.lawspec +53 -0
- package/examples/rc1-authoring.lawspec +56 -0
- package/examples-command.mjs +11 -5
- package/explain.mjs +112 -0
- package/expression-presentation.mjs +333 -0
- package/files.mjs +16 -0
- package/index.d.ts +934 -12
- package/lsp.mjs +231 -0
- package/migrate.mjs +135 -0
- package/migration-bindings.mjs +86 -0
- package/migration-cases.mjs +45 -0
- package/migration-collections.mjs +54 -0
- package/migration-correspondence.mjs +275 -0
- package/migration-generation.mjs +99 -0
- package/migration-laws.mjs +102 -0
- package/migration-records.mjs +166 -0
- package/migration-source.mjs +247 -0
- package/migration-write.mjs +156 -0
- package/native-evidence.mjs +187 -0
- package/native-examples.mjs +8 -1
- package/node-events-reporter.mjs +23 -0
- package/package.json +8 -1
- package/positional-fields.mjs +13 -0
- package/proof.d.ts +35 -0
- package/proof.mjs +174 -0
- package/scala-coverage.mjs +56 -0
- package/starter-rc1.lawspec +25 -0
- package/templates.mjs +65 -3
- package/test-command.mjs +177 -29
- package/typed-presentation.mjs +165 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"sources": [
|
|
4
|
+
"laws"
|
|
5
|
+
],
|
|
6
|
+
"machineBits": 64,
|
|
7
|
+
"targets": [
|
|
8
|
+
{
|
|
9
|
+
"language": "groovy",
|
|
10
|
+
"root": ".",
|
|
11
|
+
"nativeBindings": {
|
|
12
|
+
"types": [
|
|
13
|
+
{
|
|
14
|
+
"type": "example.payments::type::Currency",
|
|
15
|
+
"native": [
|
|
16
|
+
"domain",
|
|
17
|
+
"PaymentsDomain",
|
|
18
|
+
"CurrencyCode"
|
|
19
|
+
],
|
|
20
|
+
"constructors": [
|
|
21
|
+
{
|
|
22
|
+
"constructor": "USD",
|
|
23
|
+
"native": [
|
|
24
|
+
"domain",
|
|
25
|
+
"PaymentsDomain",
|
|
26
|
+
"CurrencyCode",
|
|
27
|
+
"Dollars"
|
|
28
|
+
],
|
|
29
|
+
"style": "unit",
|
|
30
|
+
"fields": []
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"constructor": "EUR",
|
|
34
|
+
"native": [
|
|
35
|
+
"domain",
|
|
36
|
+
"PaymentsDomain",
|
|
37
|
+
"CurrencyCode",
|
|
38
|
+
"Euros"
|
|
39
|
+
],
|
|
40
|
+
"style": "unit",
|
|
41
|
+
"fields": []
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"constructor": "GBP",
|
|
45
|
+
"native": [
|
|
46
|
+
"domain",
|
|
47
|
+
"PaymentsDomain",
|
|
48
|
+
"CurrencyCode",
|
|
49
|
+
"Pounds"
|
|
50
|
+
],
|
|
51
|
+
"style": "unit",
|
|
52
|
+
"fields": []
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "example.payments::type::Money",
|
|
58
|
+
"native": [
|
|
59
|
+
"domain",
|
|
60
|
+
"PaymentsDomain",
|
|
61
|
+
"Price"
|
|
62
|
+
],
|
|
63
|
+
"constructors": [
|
|
64
|
+
{
|
|
65
|
+
"constructor": "Money",
|
|
66
|
+
"native": [
|
|
67
|
+
"domain",
|
|
68
|
+
"PaymentsDomain",
|
|
69
|
+
"Price"
|
|
70
|
+
],
|
|
71
|
+
"style": "record",
|
|
72
|
+
"fields": [
|
|
73
|
+
{
|
|
74
|
+
"field": "amount",
|
|
75
|
+
"native": "major"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"field": "currency",
|
|
79
|
+
"native": "unit"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"type": "example.payments::type::Payment",
|
|
87
|
+
"native": [
|
|
88
|
+
"domain",
|
|
89
|
+
"PaymentsDomain",
|
|
90
|
+
"PaymentStatus"
|
|
91
|
+
],
|
|
92
|
+
"constructors": [
|
|
93
|
+
{
|
|
94
|
+
"constructor": "Paid",
|
|
95
|
+
"native": [
|
|
96
|
+
"domain",
|
|
97
|
+
"PaymentsDomain",
|
|
98
|
+
"Settled"
|
|
99
|
+
],
|
|
100
|
+
"style": "variant",
|
|
101
|
+
"fields": [
|
|
102
|
+
{
|
|
103
|
+
"field": "value",
|
|
104
|
+
"native": "price"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"constructor": "Declined",
|
|
110
|
+
"native": [
|
|
111
|
+
"domain",
|
|
112
|
+
"PaymentsDomain",
|
|
113
|
+
"Rejected"
|
|
114
|
+
],
|
|
115
|
+
"style": "variant",
|
|
116
|
+
"fields": [
|
|
117
|
+
{
|
|
118
|
+
"field": "value",
|
|
119
|
+
"native": "explanation"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"functions": [
|
|
127
|
+
{
|
|
128
|
+
"declaration": "example.payments::addFee",
|
|
129
|
+
"native": [
|
|
130
|
+
"domain",
|
|
131
|
+
"PaymentsDomain",
|
|
132
|
+
"apply_fee"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"declaration": "example.payments::roundTrip",
|
|
137
|
+
"native": [
|
|
138
|
+
"domain",
|
|
139
|
+
"PaymentsDomain",
|
|
140
|
+
"restore"
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"declaration": "example.payments::archive",
|
|
145
|
+
"native": [
|
|
146
|
+
"domain",
|
|
147
|
+
"PaymentsDomain",
|
|
148
|
+
"store"
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"generators": [
|
|
153
|
+
{
|
|
154
|
+
"type": "example.payments::type::Money",
|
|
155
|
+
"factory": [
|
|
156
|
+
"domain",
|
|
157
|
+
"PaymentGenerators",
|
|
158
|
+
"prices"
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"languageProfile": "1.0-rc.1",
|
|
166
|
+
"verification": {
|
|
167
|
+
"layers": [
|
|
168
|
+
"proof",
|
|
169
|
+
"exhaustive",
|
|
170
|
+
"property",
|
|
171
|
+
"examples",
|
|
172
|
+
"runtime",
|
|
173
|
+
"model"
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
package domain
|
|
2
|
+
|
|
3
|
+
import groovy.transform.CompileStatic
|
|
4
|
+
import lawspec.runtime.LawSpecRuntime.Maybe
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Application types, independent of generated LawSpec domain declarations.
|
|
8
|
+
* The records write out their constructors and accessors, which the Java
|
|
9
|
+
* model reads through Groovy's joint-compilation stubs.
|
|
10
|
+
*/
|
|
11
|
+
@CompileStatic
|
|
12
|
+
final class PaymentsDomain {
|
|
13
|
+
private PaymentsDomain() {}
|
|
14
|
+
|
|
15
|
+
enum CurrencyCode { Dollars, Euros, Pounds }
|
|
16
|
+
|
|
17
|
+
static record Price(BigDecimal major, CurrencyCode unit) {
|
|
18
|
+
Price(BigDecimal major, CurrencyCode unit) {
|
|
19
|
+
this.major = major
|
|
20
|
+
this.unit = unit
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
BigDecimal major() { major }
|
|
24
|
+
|
|
25
|
+
CurrencyCode unit() { unit }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static interface PaymentStatus {}
|
|
29
|
+
|
|
30
|
+
static record Settled(Price price) implements PaymentStatus {
|
|
31
|
+
Settled(Price price) { this.price = price }
|
|
32
|
+
|
|
33
|
+
Price price() { price }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static record Rejected(String explanation) implements PaymentStatus {
|
|
37
|
+
Rejected(String explanation) { this.explanation = explanation }
|
|
38
|
+
|
|
39
|
+
String explanation() { explanation }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static Price apply_fee(Price price) {
|
|
43
|
+
new Price(price.major() + new BigDecimal('0.2'), price.unit())
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static PaymentStatus restore(PaymentStatus payment) { payment }
|
|
47
|
+
|
|
48
|
+
static List<Maybe<PaymentStatus>> store(List<Maybe<PaymentStatus>> payments) { payments }
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package domain
|
|
2
|
+
|
|
3
|
+
import groovy.transform.CompileStatic
|
|
4
|
+
import org.jetbrains.jetCheck.Generator
|
|
5
|
+
|
|
6
|
+
@CompileStatic
|
|
7
|
+
final class PaymentGenerators {
|
|
8
|
+
private PaymentGenerators() {}
|
|
9
|
+
|
|
10
|
+
static Generator<PaymentsDomain.Price> prices() {
|
|
11
|
+
Generator.integers(100, 200).map { Integer cents ->
|
|
12
|
+
new PaymentsDomain.Price(new BigDecimal(BigInteger.valueOf(cents), 2), PaymentsDomain.CurrencyCode.Euros)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"sources": [
|
|
4
4
|
"laws"
|
|
5
5
|
],
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"style": "variant",
|
|
104
104
|
"fields": [
|
|
105
105
|
{
|
|
106
|
-
"field": "
|
|
106
|
+
"field": "value",
|
|
107
107
|
"native": "explanation"
|
|
108
108
|
}
|
|
109
109
|
]
|
|
@@ -145,5 +145,16 @@
|
|
|
145
145
|
]
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
]
|
|
148
|
+
],
|
|
149
|
+
"languageProfile": "1.0-rc.1",
|
|
150
|
+
"verification": {
|
|
151
|
+
"layers": [
|
|
152
|
+
"proof",
|
|
153
|
+
"exhaustive",
|
|
154
|
+
"property",
|
|
155
|
+
"examples",
|
|
156
|
+
"runtime",
|
|
157
|
+
"model"
|
|
158
|
+
]
|
|
159
|
+
}
|
|
149
160
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"sources": [
|
|
4
4
|
"laws"
|
|
5
5
|
],
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"style": "variant",
|
|
116
116
|
"fields": [
|
|
117
117
|
{
|
|
118
|
-
"field": "
|
|
118
|
+
"field": "value",
|
|
119
119
|
"native": "explanation"
|
|
120
120
|
}
|
|
121
121
|
]
|
|
@@ -161,5 +161,16 @@
|
|
|
161
161
|
]
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
]
|
|
164
|
+
],
|
|
165
|
+
"languageProfile": "1.0-rc.1",
|
|
166
|
+
"verification": {
|
|
167
|
+
"layers": [
|
|
168
|
+
"proof",
|
|
169
|
+
"exhaustive",
|
|
170
|
+
"property",
|
|
171
|
+
"examples",
|
|
172
|
+
"runtime",
|
|
173
|
+
"model"
|
|
174
|
+
]
|
|
175
|
+
}
|
|
165
176
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"sources": [
|
|
4
4
|
"laws"
|
|
5
5
|
],
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"style": "variant",
|
|
104
104
|
"fields": [
|
|
105
105
|
{
|
|
106
|
-
"field": "
|
|
106
|
+
"field": "value",
|
|
107
107
|
"native": "explanation"
|
|
108
108
|
}
|
|
109
109
|
]
|
|
@@ -145,5 +145,16 @@
|
|
|
145
145
|
]
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
]
|
|
148
|
+
],
|
|
149
|
+
"languageProfile": "1.0-rc.1",
|
|
150
|
+
"verification": {
|
|
151
|
+
"layers": [
|
|
152
|
+
"proof",
|
|
153
|
+
"exhaustive",
|
|
154
|
+
"property",
|
|
155
|
+
"examples",
|
|
156
|
+
"runtime",
|
|
157
|
+
"model"
|
|
158
|
+
]
|
|
159
|
+
}
|
|
149
160
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"sources": [
|
|
4
4
|
"laws"
|
|
5
5
|
],
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"style": "variant",
|
|
116
116
|
"fields": [
|
|
117
117
|
{
|
|
118
|
-
"field": "
|
|
118
|
+
"field": "value",
|
|
119
119
|
"native": "explanation"
|
|
120
120
|
}
|
|
121
121
|
]
|
|
@@ -161,5 +161,16 @@
|
|
|
161
161
|
]
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
]
|
|
164
|
+
],
|
|
165
|
+
"languageProfile": "1.0-rc.1",
|
|
166
|
+
"verification": {
|
|
167
|
+
"layers": [
|
|
168
|
+
"proof",
|
|
169
|
+
"exhaustive",
|
|
170
|
+
"property",
|
|
171
|
+
"examples",
|
|
172
|
+
"runtime",
|
|
173
|
+
"model"
|
|
174
|
+
]
|
|
175
|
+
}
|
|
165
176
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"sources": [
|
|
4
4
|
"laws"
|
|
5
5
|
],
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"style": "variant",
|
|
104
104
|
"fields": [
|
|
105
105
|
{
|
|
106
|
-
"field": "
|
|
106
|
+
"field": "value",
|
|
107
107
|
"native": "explanation"
|
|
108
108
|
}
|
|
109
109
|
]
|
|
@@ -145,5 +145,16 @@
|
|
|
145
145
|
]
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
]
|
|
148
|
+
],
|
|
149
|
+
"languageProfile": "1.0-rc.1",
|
|
150
|
+
"verification": {
|
|
151
|
+
"layers": [
|
|
152
|
+
"proof",
|
|
153
|
+
"exhaustive",
|
|
154
|
+
"property",
|
|
155
|
+
"examples",
|
|
156
|
+
"runtime",
|
|
157
|
+
"model"
|
|
158
|
+
]
|
|
159
|
+
}
|
|
149
160
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"sources": [
|
|
4
4
|
"laws"
|
|
5
5
|
],
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"style": "variant",
|
|
119
119
|
"fields": [
|
|
120
120
|
{
|
|
121
|
-
"field": "
|
|
121
|
+
"field": "value",
|
|
122
122
|
"native": "explanation"
|
|
123
123
|
}
|
|
124
124
|
]
|
|
@@ -163,5 +163,16 @@
|
|
|
163
163
|
]
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
]
|
|
166
|
+
],
|
|
167
|
+
"languageProfile": "1.0-rc.1",
|
|
168
|
+
"verification": {
|
|
169
|
+
"layers": [
|
|
170
|
+
"proof",
|
|
171
|
+
"exhaustive",
|
|
172
|
+
"property",
|
|
173
|
+
"examples",
|
|
174
|
+
"runtime",
|
|
175
|
+
"model"
|
|
176
|
+
]
|
|
177
|
+
}
|
|
167
178
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"sources": [
|
|
4
|
+
"laws"
|
|
5
|
+
],
|
|
6
|
+
"machineBits": 64,
|
|
7
|
+
"targets": [
|
|
8
|
+
{
|
|
9
|
+
"language": "scala",
|
|
10
|
+
"root": ".",
|
|
11
|
+
"nativeBindings": {
|
|
12
|
+
"types": [
|
|
13
|
+
{
|
|
14
|
+
"type": "example.payments::type::Currency",
|
|
15
|
+
"native": [
|
|
16
|
+
"domain",
|
|
17
|
+
"PaymentsDomain",
|
|
18
|
+
"CurrencyCode"
|
|
19
|
+
],
|
|
20
|
+
"constructors": [
|
|
21
|
+
{
|
|
22
|
+
"constructor": "USD",
|
|
23
|
+
"native": [
|
|
24
|
+
"domain",
|
|
25
|
+
"PaymentsDomain",
|
|
26
|
+
"CurrencyCode",
|
|
27
|
+
"Dollars"
|
|
28
|
+
],
|
|
29
|
+
"style": "unit",
|
|
30
|
+
"fields": []
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"constructor": "EUR",
|
|
34
|
+
"native": [
|
|
35
|
+
"domain",
|
|
36
|
+
"PaymentsDomain",
|
|
37
|
+
"CurrencyCode",
|
|
38
|
+
"Euros"
|
|
39
|
+
],
|
|
40
|
+
"style": "unit",
|
|
41
|
+
"fields": []
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"constructor": "GBP",
|
|
45
|
+
"native": [
|
|
46
|
+
"domain",
|
|
47
|
+
"PaymentsDomain",
|
|
48
|
+
"CurrencyCode",
|
|
49
|
+
"Pounds"
|
|
50
|
+
],
|
|
51
|
+
"style": "unit",
|
|
52
|
+
"fields": []
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "example.payments::type::Money",
|
|
58
|
+
"native": [
|
|
59
|
+
"domain",
|
|
60
|
+
"PaymentsDomain",
|
|
61
|
+
"Price"
|
|
62
|
+
],
|
|
63
|
+
"constructors": [
|
|
64
|
+
{
|
|
65
|
+
"constructor": "Money",
|
|
66
|
+
"native": [
|
|
67
|
+
"domain",
|
|
68
|
+
"PaymentsDomain",
|
|
69
|
+
"Price"
|
|
70
|
+
],
|
|
71
|
+
"style": "record",
|
|
72
|
+
"fields": [
|
|
73
|
+
{
|
|
74
|
+
"field": "amount",
|
|
75
|
+
"native": "major"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"field": "currency",
|
|
79
|
+
"native": "unit"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"type": "example.payments::type::Payment",
|
|
87
|
+
"native": [
|
|
88
|
+
"domain",
|
|
89
|
+
"PaymentsDomain",
|
|
90
|
+
"PaymentStatus"
|
|
91
|
+
],
|
|
92
|
+
"constructors": [
|
|
93
|
+
{
|
|
94
|
+
"constructor": "Paid",
|
|
95
|
+
"native": [
|
|
96
|
+
"domain",
|
|
97
|
+
"PaymentsDomain",
|
|
98
|
+
"Settled"
|
|
99
|
+
],
|
|
100
|
+
"style": "variant",
|
|
101
|
+
"fields": [
|
|
102
|
+
{
|
|
103
|
+
"field": "value",
|
|
104
|
+
"native": "price"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"constructor": "Declined",
|
|
110
|
+
"native": [
|
|
111
|
+
"domain",
|
|
112
|
+
"PaymentsDomain",
|
|
113
|
+
"Rejected"
|
|
114
|
+
],
|
|
115
|
+
"style": "variant",
|
|
116
|
+
"fields": [
|
|
117
|
+
{
|
|
118
|
+
"field": "value",
|
|
119
|
+
"native": "explanation"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"functions": [
|
|
127
|
+
{
|
|
128
|
+
"declaration": "example.payments::addFee",
|
|
129
|
+
"native": [
|
|
130
|
+
"domain",
|
|
131
|
+
"PaymentsDomain",
|
|
132
|
+
"apply_fee"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"declaration": "example.payments::roundTrip",
|
|
137
|
+
"native": [
|
|
138
|
+
"domain",
|
|
139
|
+
"PaymentsDomain",
|
|
140
|
+
"restore"
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"declaration": "example.payments::archive",
|
|
145
|
+
"native": [
|
|
146
|
+
"domain",
|
|
147
|
+
"PaymentsDomain",
|
|
148
|
+
"store"
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"generators": [
|
|
153
|
+
{
|
|
154
|
+
"type": "example.payments::type::Money",
|
|
155
|
+
"factory": [
|
|
156
|
+
"domain",
|
|
157
|
+
"PaymentGenerators",
|
|
158
|
+
"prices"
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"languageProfile": "1.0-rc.1",
|
|
166
|
+
"verification": {
|
|
167
|
+
"layers": [
|
|
168
|
+
"proof",
|
|
169
|
+
"exhaustive",
|
|
170
|
+
"property",
|
|
171
|
+
"examples",
|
|
172
|
+
"runtime",
|
|
173
|
+
"model"
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package domain
|
|
2
|
+
|
|
3
|
+
// Application-owned types; no generated LawSpec domain declarations.
|
|
4
|
+
object PaymentsDomain {
|
|
5
|
+
enum CurrencyCode {
|
|
6
|
+
case Dollars, Euros, Pounds
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
final case class Price(major: BigDecimal, unit: CurrencyCode)
|
|
10
|
+
|
|
11
|
+
sealed trait PaymentStatus
|
|
12
|
+
final case class Settled(price: Price) extends PaymentStatus
|
|
13
|
+
final case class Rejected(explanation: String) extends PaymentStatus
|
|
14
|
+
|
|
15
|
+
def apply_fee(price: Price): Price = Price(price.major + BigDecimal("0.2"), price.unit)
|
|
16
|
+
def restore(payment: PaymentStatus): PaymentStatus = payment
|
|
17
|
+
def store(payments: List[Option[PaymentStatus]]): List[Option[PaymentStatus]] = payments
|
|
18
|
+
}
|