Skip to content

Commit

Permalink
Merge branch 'main' into update/sbt-1.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
konnov authored Nov 7, 2024
2 parents 25ba751 + 759b3f4 commit c86da23
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
40 changes: 20 additions & 20 deletions docs/src/lang/variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ To make it easier to represent the fruits, we can introduce variants together wi
user-defined constructors for each option::

```tla
\* @typeAlias: FRUIT = Apple(Str) | Orange(Bool);
\* @typeAlias: fruit = Apple(Str) | Orange(Bool);
\* @type: Str => FRUIT;
\* @type: Str => $fruit;
Apple(color) == Variant("Apple", color)
\* @type: Bool => FRUIT;
\* @type: Bool => $fruit;
Orange(seedless) == Variant("Orange", seedless)
```

Expand All @@ -92,20 +92,20 @@ Orange(TRUE)
Variants can wrap records, for when we want to represent compound data with named fields:

```tla
\* @typeAlias: DRINK =
\* @typeAlias: drink =
\* Water({ sparkling: Bool })
\* | Beer({ malt: Str, strength: Int });
\*
\* @type: Bool => DRINK;
\* @type: Bool => $drink;
Water(sparkling) == Variant("Water", [ sparkling |-> sparkling ])
\* @type: (Str, Int) => DRINK;
\* @type: (Str, Int) => $drink;
Beer(malt, strength) == Variant("Beer", [ malt |-> malt, strength |-> strength ])
```

Once a variant is constructed, it becomes opaque to the type checker, that is,
the type checker only knows that `Water(TRUE)` and `Beer("Dark", 5)` are both
of type `DRINK`. This is exactly what we want, in order to combine these values
of type `drink`. This is exactly what we want, in order to combine these values
in a single set. However, we have lost the ability to access the fields of
these values. To deconstruct values of a variant type, we have to use other
operators, presented below.
Expand All @@ -115,7 +115,7 @@ untyped TLA+, we can filter a set of variants:

```tla
LET Drinks == { Water(TRUE), Water(FALSE), Beer("Radler", 2) } IN
\E d \in VariantFilter("Beer", Drink):
\E d \in VariantFilter("Beer", Drinks):
d.strength < 3
```

Expand Down Expand Up @@ -195,14 +195,14 @@ type variable that captures other options in the variant type.
**Example in TLA+:**

```tla
\* @typeAlias: DRINK =
\* @typeAlias: drink =
\* Water({ sparkling: Bool })
\* | Beer({ malt: Str, strength: Int });
\*
\* @type: Bool => DRINK;
\* @type: Bool => $drink;
Water(sparkling) == Variant("Water", [ sparkling |-> sparkling ])
\* @type: (Str, Int) => DRINK;
\* @type: (Str, Int) => $drink;
Beer(malt, strength) == Variant("Beer", [ malt |-> malt, strength |-> strength ])
```

Expand Down Expand Up @@ -260,14 +260,14 @@ values that were packed with `Variant`.
**Example in TLA+:**

```tla
\* @typeAlias: DRINK =
\* @typeAlias: drink =
\* Water({ sparkling: Bool })
\* | Beer({ malt: Str, strength: Int });
\*
\* @type: Bool => DRINK;
\* @type: Bool => $drink;
Water(sparkling) == Variant("Water", [ sparkling |-> sparkling ])
\* @type: (Str, Int) => DRINK;
\* @type: (Str, Int) => $drink;
Beer(malt, strength) == Variant("Beer", [ malt |-> malt, strength |-> strength ])
LET Drinks == { Water(TRUE), Water(FALSE), Beer("Radler", 2) } IN
Expand Down Expand Up @@ -303,14 +303,14 @@ Otherwise, the operator returns `defaultValue`.
**Example in TLA+:**

```tla
\* @typeAlias: DRINK =
\* @typeAlias: drink =
\* Water({ sparkling: Bool })
\* | Beer({ malt: Str, strength: Int });
\*
\* @type: Bool => DRINK;
\* @type: Bool => $drink;
Water(sparkling) == Variant("Water", [ sparkling |-> sparkling ])
\* @type: (Str, Int) => DRINK;
\* @type: (Str, Int) => $drink;
Beer(malt, strength) == Variant("Beer", [ malt |-> malt, strength |-> strength ])
LET water == Water(TRUE) IN
Expand Down Expand Up @@ -348,14 +348,14 @@ is always constructed via `Variant`, unless the operator is used with the right
**Example in TLA+:**

```tla
\* @typeAlias: DRINK =
\* @typeAlias: drink =
\* Water({ sparkling: Bool })
\* | Beer({ malt: Str, strength: Int });
\*
\* @type: Bool => DRINK;
\* @type: Bool => $drink;
Water(sparkling) == Variant("Water", [ sparkling |-> sparkling ])
\* @type: (Str, Int) => DRINK;
\* @type: (Str, Int) => $drink;
Beer(malt, strength) == Variant("Beer", [ malt |-> malt, strength |-> strength ])
LET drink == Beer("Dunkles", 4) IN
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object Dependencies {
val zio = "dev.zio" %% "zio" % zioVersion
// Keep up to sync with version in plugins.sbt
val zioGrpcCodgen = "com.thesamet.scalapb.zio-grpc" %% "zio-grpc-codegen" % "0.6.0-test3" % "provided"
val grpcNetty = "io.grpc" % "grpc-netty" % "1.68.0"
val grpcNetty = "io.grpc" % "grpc-netty" % "1.68.1"
val scalapbRuntimGrpc =
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion
// Ensures we have access to commonly used protocol buffers (e.g., google.protobuf.Struct)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.4
sbt.version=1.10.5
2 changes: 1 addition & 1 deletion project/sbt-changeling/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "systems.informal"

libraryDependencies ++= Seq(
"org.scala-sbt" % "sbt" % "1.10.4"
"org.scala-sbt" % "sbt" % "1.10.5"
)

lazy val sbt_changeling = (project in file("."))
Expand Down
2 changes: 1 addition & 1 deletion project/sbt-changeling/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.4
sbt.version=1.10.5

0 comments on commit c86da23

Please sign in to comment.