Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the empty tuple for the unit #1406

Merged
merged 8 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The latest supported node version is now bounded at <= 20, which covers the
latest LTS. (#1380)
- Shadowing names are now supported, which means that the same name can be redefined
in nested scopes (#1394)
in nested scopes. (#1394)
- The canonical unit type is now the empty tuple, `()`, rather than the empty
record, `{}`. This should only affect invisible things to do with sum type
constructors. (#1401)

### Deprecated
### Removed
Expand Down
8 changes: 4 additions & 4 deletions doc/lang.md
Original file line number Diff line number Diff line change
Expand Up @@ -1300,14 +1300,14 @@ sets of records: (1) It often confuses beginners, (2) It can be expressed with

### Tuples

In contrast to TLA+, Quint tuples have length of at least 2.
If you need lists, use lists.

```scala
// Tuple constructor: << e_1, ..., e_n >>
// Warning: n >= 2
(e_1, ..., e_n)
Tup(e_1, ..., e_n)
// The empty tuple is also the canonical unit type
// <<>>
()
Tup()
// t[1], t[2], t[3], t[4], ... , t[50]
t._1
t._2
Expand Down
45 changes: 28 additions & 17 deletions quint/apalache-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,34 +224,45 @@ An example execution:

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

<!-- !test in can convert booleans.qnt to TLA+ -->
<!-- !test in can convert ApalacheCompliation.qnt to TLA+ -->
```
quint compile --target tlaplus ../examples/language-features/booleans.qnt
quint compile --target tlaplus ./testFixture/ApalacheCompilation.qnt
bugarela marked this conversation as resolved.
Show resolved Hide resolved
```

<!-- !test out can convert booleans.qnt to TLA+ -->
<!-- !test out can convert ApalacheCompliation.qnt to TLA+ -->
```
------------------------------- MODULE booleans -------------------------------
-------------------------- MODULE ApalacheCompilation --------------------------

EXTENDS Integers, Sequences, FiniteSets, TLC, Apalache
EXTENDS Integers, Sequences, FiniteSets, TLC, Apalache, Variants

VARIABLE b
VARIABLE x

step ==
(b \/ TRUE)
/\ ~(b /\ FALSE)
/\ (b => b)
/\ (b <=> b)
/\ b = b
/\ b /= (~b)
/\ b' := (~b)
A == Variant("A", <<>>)

init == b' := TRUE
B(__BParam_27) == Variant("B", __BParam_27)

foo_bar(id__123_31) == id__123_31

importedValue == 0

ApalacheCompilation_ModuleToInstantiate_C == 0

step == x' := (x + 1)

inv == x >= 0

ApalacheCompilation_ModuleToInstantiate_instantiatedValue ==
ApalacheCompilation_ModuleToInstantiate_C

init ==
x'
:= (importedValue
+ ApalacheCompilation_ModuleToInstantiate_instantiatedValue)

================================================================================
```

### Test that we can compile a module with imports and instances to TLA+
### Test that we can compile a module to TLA+ that instantiates but has not declarations
bugarela marked this conversation as resolved.
Show resolved Hide resolved


<!-- !test in can convert clockSync3.qnt to TLA+ -->
Expand All @@ -266,7 +277,7 @@ which leaves nothing, thanks to the way clockSync3 is instanced.
```
------------------------------ MODULE clockSync3 ------------------------------

EXTENDS Integers, Sequences, FiniteSets, TLC, Apalache
EXTENDS Integers, Sequences, FiniteSets, TLC, Apalache, Variants

================================================================================
```
2 changes: 1 addition & 1 deletion quint/io-cli-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ rm xTest.itf.json

<!-- !test out variants in itf -->
```
[{"#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"}}}]
[{"#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"}}}]
```

### FAIL on parsing filenames with different casing
Expand Down
3 changes: 2 additions & 1 deletion quint/src/generated/Quint.g4
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ expr: // apply a built-in operator via the dot notation
| 'all' '{' expr (',' expr)* ','? '}' # actionAll
| 'any' '{' expr (',' expr)* ','? '}' # actionAny
| ( qualId | INT | BOOL | STRING) # literalOrId
// a tuple constructor, the form tup(...) is just an operator call
// a tuple constructor, the form Tup(...) is just an operator call
| '(' expr ',' expr (',' expr)* ','? ')' # tuple
| '(' ')' # unit
// short-hand syntax for pairs, mainly designed for maps
| expr '->' expr # pair
| '{' recElem (',' recElem)* ','? '}' # record
Expand Down
2 changes: 1 addition & 1 deletion quint/src/generated/Quint.interp

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions quint/src/generated/QuintListener.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading