Skip to content

Commit dfd0f7f

Browse files
authored
Merge pull request #1406 from informalsystems/1401/empty-tuple-unit
Use the empty tuple for the unit
2 parents 393ec51 + a43eaaa commit dfd0f7f

20 files changed

+695
-586
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- The latest supported node version is now bounded at <= 20, which covers the
2121
latest LTS. (#1380)
2222
- Shadowing names are now supported, which means that the same name can be redefined
23-
in nested scopes (#1394)
23+
in nested scopes. (#1394)
24+
- The canonical unit type is now the empty tuple, `()`, rather than the empty
25+
record, `{}`. This should only affect invisible things to do with sum type
26+
constructors. (#1401)
2427

2528
### Deprecated
2629
### Removed

doc/lang.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1300,14 +1300,14 @@ sets of records: (1) It often confuses beginners, (2) It can be expressed with
13001300

13011301
### Tuples
13021302

1303-
In contrast to TLA+, Quint tuples have length of at least 2.
1304-
If you need lists, use lists.
1305-
13061303
```scala
13071304
// Tuple constructor: << e_1, ..., e_n >>
1308-
// Warning: n >= 2
13091305
(e_1, ..., e_n)
13101306
Tup(e_1, ..., e_n)
1307+
// The empty tuple is also the canonical unit type
1308+
// <<>>
1309+
()
1310+
Tup()
13111311
// t[1], t[2], t[3], t[4], ... , t[50]
13121312
t._1
13131313
t._2

quint/apalache-tests.md

+28-17
Original file line numberDiff line numberDiff line change
@@ -224,34 +224,45 @@ An example execution:
224224

225225
### Test that we can compile to TLA+ of the expected form
226226

227-
<!-- !test in can convert booleans.qnt to TLA+ -->
227+
<!-- !test in can convert ApalacheCompliation.qnt to TLA+ -->
228228
```
229-
quint compile --target tlaplus ../examples/language-features/booleans.qnt
229+
quint compile --target tlaplus ./testFixture/ApalacheCompilation.qnt
230230
```
231231

232-
<!-- !test out can convert booleans.qnt to TLA+ -->
232+
<!-- !test out can convert ApalacheCompliation.qnt to TLA+ -->
233233
```
234-
------------------------------- MODULE booleans -------------------------------
234+
-------------------------- MODULE ApalacheCompilation --------------------------
235235
236-
EXTENDS Integers, Sequences, FiniteSets, TLC, Apalache
236+
EXTENDS Integers, Sequences, FiniteSets, TLC, Apalache, Variants
237237
238-
VARIABLE b
238+
VARIABLE x
239239
240-
step ==
241-
(b \/ TRUE)
242-
/\ ~(b /\ FALSE)
243-
/\ (b => b)
244-
/\ (b <=> b)
245-
/\ b = b
246-
/\ b /= (~b)
247-
/\ b' := (~b)
240+
A == Variant("A", "U_OF_UNIT")
248241
249-
init == b' := TRUE
242+
B(__BParam_27) == Variant("B", __BParam_27)
243+
244+
foo_bar(id__123_31) == id__123_31
245+
246+
importedValue == 0
247+
248+
ApalacheCompilation_ModuleToInstantiate_C == 0
249+
250+
step == x' := (x + 1)
251+
252+
inv == x >= 0
253+
254+
ApalacheCompilation_ModuleToInstantiate_instantiatedValue ==
255+
ApalacheCompilation_ModuleToInstantiate_C
256+
257+
init ==
258+
x'
259+
:= (importedValue
260+
+ ApalacheCompilation_ModuleToInstantiate_instantiatedValue)
250261
251262
================================================================================
252263
```
253264

254-
### Test that we can compile a module with imports and instances to TLA+
265+
### Test that we can compile a module to TLA+ that instantiates but has no declarations
255266

256267

257268
<!-- !test in can convert clockSync3.qnt to TLA+ -->
@@ -266,7 +277,7 @@ which leaves nothing, thanks to the way clockSync3 is instanced.
266277
```
267278
------------------------------ MODULE clockSync3 ------------------------------
268279
269-
EXTENDS Integers, Sequences, FiniteSets, TLC, Apalache
280+
EXTENDS Integers, Sequences, FiniteSets, TLC, Apalache, Variants
270281
271282
================================================================================
272283
```

quint/io-cli-tests.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ rm xTest.itf.json
11301130

11311131
<!-- !test out variants in itf -->
11321132
```
1133-
[{"#meta":{"index":0},"x":{"tag":"None","value":{}}},{"#meta":{"index":1},"x":{"tag":"Some","value":{"#bigint":"1"}}},{"#meta":{"index":2},"x":{"tag":"Some","value":{"#bigint":"2"}}}]
1133+
[{"#meta":{"index":0},"x":{"tag":"None","value":{"#tup":[]}}},{"#meta":{"index":1},"x":{"tag":"Some","value":{"#bigint":"1"}}},{"#meta":{"index":2},"x":{"tag":"Some","value":{"#bigint":"2"}}}]
11341134
```
11351135

11361136
### FAIL on parsing filenames with different casing

quint/src/apalache.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import type { Buffer } from 'buffer'
3939
import type { PackageDefinition as ProtoPackageDefinition } from '@grpc/proto-loader'
4040

4141
const APALACHE_SERVER_URI = 'localhost:8822'
42-
const APALACHE_VERSION_TAG = '0.44.7'
42+
const APALACHE_VERSION_TAG = '0.44.9'
4343
// TODO: used by GitHub api approach: https://github.com/informalsystems/quint/issues/1124
4444
// const APALACHE_TGZ = 'apalache.tgz'
4545

quint/src/generated/Quint.g4

+2-1
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ expr: // apply a built-in operator via the dot notation
176176
| 'all' '{' expr (',' expr)* ','? '}' # actionAll
177177
| 'any' '{' expr (',' expr)* ','? '}' # actionAny
178178
| ( qualId | INT | BOOL | STRING) # literalOrId
179-
// a tuple constructor, the form tup(...) is just an operator call
179+
// a tuple constructor, the form Tup(...) is just an operator call
180180
| '(' expr ',' expr (',' expr)* ','? ')' # tuple
181+
| '(' ')' # unit
181182
// short-hand syntax for pairs, mainly designed for maps
182183
| expr '->' expr # pair
183184
| '{' recElem (',' recElem)* ','? '}' # record

quint/src/generated/Quint.interp

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

quint/src/generated/QuintListener.ts

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)