Skip to content

Commit 4b6d693

Browse files
authored
Merge pull request #7833 from dvirf1/documentation-changes
minor fixes to the documentation
2 parents 283b095 + d85b25a commit 4b6d693

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

docs/docs/reference/contextual/given-clauses.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def max[T](x: T, y: T)(given ord: Ord[T]): T =
1818
Here, `ord` is an _implicit parameter_ introduced with a `given` clause.
1919
The `max` method can be applied as follows:
2020
```scala
21-
max(2, 3)(given IntOrd)
21+
max(2, 3)(given intOrd)
2222
```
23-
The `(given IntOrd)` part passes `IntOrd` as an argument for the `ord` parameter. But the point of
23+
The `(given intOrd)` part passes `intOrd` as an argument for the `ord` parameter. But the point of
2424
implicit parameters is that this argument can also be left out (and it usually is). So the following
2525
applications are equally valid:
2626
```scala
@@ -60,8 +60,8 @@ With this setup, the following calls are all well-formed, and they all normalize
6060
```scala
6161
minimum(xs)
6262
maximum(xs)(given descending)
63-
maximum(xs)(given descending(given ListOrd))
64-
maximum(xs)(given descending(given ListOrd(given IntOrd)))
63+
maximum(xs)(given descending(given listOrd))
64+
maximum(xs)(given descending(given listOrd(given intOrd)))
6565
```
6666

6767
## Multiple Given Clauses
@@ -92,9 +92,9 @@ But `f(global)(given sym, kind)` would give a type error.
9292
The method `summon` in `Predef` returns the given instance of a specific type. For example,
9393
the given instance for `Ord[List[Int]]` is produced by
9494
```scala
95-
summon[Ord[List[Int]]] // reduces to ListOrd given IntOrd
95+
summon[Ord[List[Int]]] // reduces to listOrd given intOrd
9696
```
97-
The `summon` method is simply defined as the (non-widening) identity function over a implicit parameter.
97+
The `summon` method is simply defined as the (non-widening) identity function over an implicit parameter.
9898
```scala
9999
def summon[T](given x: T): x.type = x
100100
```

docs/docs/reference/contextual/multiversal-equality.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ does not work, since it refers to the covariant parameter `T` in a nonvariant co
171171
```scala
172172
def contains[U >: T](x: U): Boolean
173173
```
174-
This generic version of `contains` is the one used in the current (Scala 2.12) version of `List`.
174+
This generic version of `contains` is the one used in the current (Scala 2.13) version of `List`.
175175
It looks different but it admits exactly the same applications as the `contains(x: Any)` definition we started with.
176176
However, we can make it more useful (i.e. restrictive) by adding an `Eql` parameter:
177177
```scala

docs/docs/reference/contextual/relationship-implicits.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ Explicit arguments to parameters of given clauses _must_ be written using `given
8686
mirroring the definition syntax. E.g, `max(2, 3)(given IntOrd`).
8787
Scala 2 uses normal applications `max(2, 3)(IntOrd)` instead. The Scala 2 syntax has some inherent ambiguities and restrictions which are overcome by the new syntax. For instance, multiple implicit parameter lists are not available in the old syntax, even though they can be simulated using auxiliary objects in the "Aux" pattern.
8888

89-
The `the` method corresponds to `implicitly` in Scala 2.
89+
The `summon` method corresponds to `implicitly` in Scala 2.
9090
It is precisely the same as the `the` method in Shapeless.
91-
The difference between `the` (in both versions) and `implicitly` is
92-
that `the` can return a more precise type than the type that was
91+
The difference between `summon` (or `the`) and `implicitly` is
92+
that `summon` can return a more precise type than the type that was
9393
asked for.
9494

9595
### Context Bounds
@@ -108,7 +108,7 @@ def (c: Circle) circumference: Double = c.radius * math.Pi * 2
108108
```
109109
could be simulated to some degree by
110110
```scala
111-
implicit class CircleDeco(c: Circle) extends AnyVal {
111+
implicit class CircleDecorator(c: Circle) extends AnyVal {
112112
def circumference: Double = c.radius * math.Pi * 2
113113
}
114114
```
@@ -162,12 +162,12 @@ given Position = pos
162162

163163
An abstract implicit `val` or `def` in Scala 2 can be expressed in Dotty using a regular abstract definition and an alias given. E.g., Scala 2's
164164
```scala
165-
implicit def symDeco: SymDeco
165+
implicit def symDecorator: SymDecorator
166166
```
167167
can be expressed in Dotty as
168168
```scala
169-
def symDeco: SymDeco
170-
given SymDeco = symDeco
169+
def symDecorator: SymDecorator
170+
given SymDecorator = symDecorator
171171
```
172172

173173
## Implementation Status and Timeline

docs/docs/reference/new-types/dependent-function-types.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ val extractor: (e: Entry) => e.Key = extractKey // a dependent function value
1717
```
1818
Scala already has _dependent methods_, i.e. methods where the result
1919
type refers to some of the parameters of the method. Method
20-
`extractKey` is an example. Its result type, `e.key` refers its
20+
`extractKey` is an example. Its result type, `e.Key` refers its
2121
parameter `e` (we also say, `e.Key` _depends_ on `e`). But so far it
2222
was not possible to turn such methods into function values, so that
2323
they can be passed as parameters to other functions, or returned as
@@ -30,8 +30,8 @@ In Dotty this is now possible. The type of the `extractor` value above is
3030
(e: Entry) => e.Key
3131
```
3232

33-
This type describes function values that take any argument `x` of type
34-
`Entry` and return a result of type `x.Key`.
33+
This type describes function values that take any argument `e` of type
34+
`Entry` and return a result of type `e.Key`.
3535

3636
Recall that a normal function type `A => B` is represented as an
3737
instance of the `Function1` trait (i.e. `Function1[A, B]`) and

docs/docs/reference/new-types/union-types-spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ case _: (A | B) => ...
3838
A & (B | C) =:= A & B | A & C
3939
```
4040

41-
From these rules it follows that the _least upper bound_ (lub) of a set of type
41+
From these rules it follows that the _least upper bound_ (lub) of a set of types
4242
is the union of these types. This replaces the
4343
[definition of least upper bound in the Scala 2 specification](https://www.scala-lang.org/files/archive/spec/2.12/03-types.html#least-upper-bounds-and-greatest-lower-bounds).
4444

4545
## Motivation
4646

4747
The primary reason for introducing union types in Scala is that they allow us to
48-
guarantee that for every set of type, we can always form a finite lub. This is
48+
guarantee that for every set of types, we can always form a finite lub. This is
4949
both useful in practice (infinite lubs in Scala 2 were approximated in an ad-hoc
5050
way, resulting in imprecise and sometimes incredibly long types) and in theory
5151
(the type system of Scala 3 is based on the

docs/docs/reference/other-new-features/export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Export clauses can appear in classes or they can appear at the top-level. An exp
9393

9494
It is a standard recommendation to prefer composition over inheritance. This is really an application of the principle of least power: Composition treats components as blackboxes whereas inheritance can affect the internal workings of components through overriding. Sometimes the close coupling implied by inheritance is the best solution for a problem, but where this is not necessary the looser coupling of composition is better.
9595

96-
So far, object oriented languages including Scala made it much easer to use inheritance than composition. Inheritance only requires an `extends` clause whereas composition required a verbose elaboration of a sequence of forwarders. So in that sense, OO languages are pushing
96+
So far, object oriented languages including Scala made it much easier to use inheritance than composition. Inheritance only requires an `extends` clause whereas composition required a verbose elaboration of a sequence of forwarders. So in that sense, OO languages are pushing
9797
programmers to a solution that is often too powerful. Export clauses redress the balance. They make composition relationships as concise and easy to express as inheritance relationships. Export clauses also offer more flexibility than extends clauses since members can be renamed or omitted.
9898

9999
Export clauses also fill a gap opened by the shift from package objects to toplevel definitions. One occasionally useful idiom that gets lost in this shift is a package object inheriting from some class. The idiom is often used in a facade like pattern, to make members

0 commit comments

Comments
 (0)