Skip to content

Commit 0f1d350

Browse files
authored
Merge pull request #11062 from michelou/scala3-docs
[docs/reference] more fixes in Markdown files
2 parents 96401b6 + cef31fb commit 0f1d350

22 files changed

+67
-61
lines changed

docs/docs/reference/changed-features/implicit-conversions-spec.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ implicit val myConverter: Int => String = _.toString
8181
implicit val myConverter: Conversion[Int, String] = _.toString
8282
```
8383

84-
Note that implicit conversions are also affected by the
85-
[changes to implicit resolution](implicit-resolution.md) between Scala 2 and
86-
Scala 3.
84+
Note that implicit conversions are also affected by the [changes to implicit resolution](implicit-resolution.md) between Scala 2 and Scala 3.
8785

8886
## Motivation for the changes
8987

@@ -99,24 +97,20 @@ val x: String = 1 // Scala 2: assigns "abc" to x
9997
// Scala 3: type error
10098
```
10199

102-
This snippet contains a type error. The right hand side of `val x`
100+
This snippet contains a type error. The right-hand side of `val x`
103101
does not conform to type `String`. In Scala 2, the compiler will use
104102
`m` as an implicit conversion from `Int` to `String`, whereas Scala 3
105103
will report a type error, because `Map` isn't an instance of
106104
`Conversion`.
107105

108106
## Migration path
109107

110-
Implicit values that are used as views should see their type changed
111-
to `Conversion`.
108+
Implicit values that are used as views should see their type changed to `Conversion`.
112109

113110
For the migration of implicit conversions that are affected by the
114-
changes to implicit resolution, refer to the [Changes in Implicit
115-
Resolution](implicit-resolution.md) for more information.
111+
changes to implicit resolution, refer to the [Changes in Implicit Resolution](implicit-resolution.md) for more information.
116112

117113
## Reference
118114

119-
For more information about implicit resolution, see [Changes in
120-
Implicit Resolution](implicit-resolution.md).
121-
Other details are available in
122-
[PR #2065](https://github.com/lampepfl/dotty/pull/2065).
115+
For more information about implicit resolution, see [Changes in Implicit Resolution](implicit-resolution.md).
116+
Other details are available in [PR #2065](https://github.com/lampepfl/dotty/pull/2065).

docs/docs/reference/changed-features/numeric-literals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ BigFloat.FromDigits.fromDigits("1e100000000000")
199199
Evaluating this expression throws a `NumberTooLarge` exception at run time. We would like it to
200200
produce a compile-time error instead. We can achieve this by tweaking the `BigFloat` class
201201
with a small dose of metaprogramming. The idea is to turn the `fromDigits` method
202-
into a macro, i.e. make it an inline method with a splice as right hand side.
202+
into a macro, i.e. make it an inline method with a splice as right-hand side.
203203
To do this, replace the `FromDigits` instance in the `BigFloat` object by the following two definitions:
204204

205205
```scala

docs/docs/reference/changed-features/overload-resolution.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ as follows:
4040
resolution yields several competing alternatives when `n >= 1` parameter lists are taken
4141
into account, then resolution re-tried using `n + 1` argument lists.
4242

43-
This change is motivated by the new language feature [extension
44-
methods](../contextual/extension-methods.md), where emerges the need to do
43+
This change is motivated by the new language feature
44+
[extension methods](../contextual/extension-methods.md), where emerges the need to do
4545
overload resolution based on additional argument blocks.
4646

4747
## Parameter Types of Function Values
@@ -51,12 +51,14 @@ pass such values in the first argument list of an overloaded application, provid
5151
that the remaining parameters suffice for picking a variant of the overloaded function.
5252
For example, the following code compiles in Scala 3, while it results in an
5353
missing parameter type error in Scala2:
54+
5455
```scala
5556
def f(x: Int, f2: Int => Int) = f2(x)
5657
def f(x: String, f2: String => String) = f2(x)
5758
f("a", _.toUpperCase)
5859
f(2, _ * 2)
5960
```
61+
6062
To make this work, the rules for overloading resolution in [SLS §6.26.3](https://www.scala-lang.org/files/archive/spec/2.13/06-expressions.html#overloading-resolution) are modified
6163
as follows:
6264

@@ -75,11 +77,15 @@ is determined as followed:
7577
- Otherwise the known type of `E` is the result of typing `E` with an undefined expected type.
7678

7779
A pattern matching closure
80+
7881
```scala
7982
{ case P1 => B1 ... case P_n => B_n }
8083
````
84+
8185
is treated as if it was expanded to the function value
86+
8287
```scala
8388
x => x match { case P1 => B1 ... case P_n => B_n }
8489
```
90+
8591
and is therefore also approximated with a `? => ?` type.

docs/docs/reference/changed-features/pattern-bindings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ From Scala 3.1 on, type checking rules will be tightened so that warnings are re
1313
```scala
1414
val xs: List[Any] = List(1, 2, 3)
1515
val (x: String) :: _ = xs // error: pattern's type String is more specialized
16-
// than the right hand side expression's type Any
16+
// than the right-hand side expression's type Any
1717
```
1818
This code gives a compile-time warning in Scala 3.1 (and also in Scala 3.0 under the `-source 3.1` setting) whereas it will fail at runtime with a `ClassCastException` in Scala 2. In Scala 3.1, a pattern binding is only allowed if the pattern is _irrefutable_, that is, if the right-hand side's type conforms to the pattern's type. For instance, the following is OK:
1919
```scala
@@ -38,7 +38,7 @@ Analogous changes apply to patterns in `for` expressions. For instance:
3838
```scala
3939
val elems: List[Any] = List((1, 2), "hello", (3, 4))
4040
for (x, y) <- elems yield (y, x) // error: pattern's type (Any, Any) is more specialized
41-
// than the right hand side expression's type Any
41+
// than the right-hand side expression's type Any
4242
```
4343
This code gives a compile-time warning in Scala 3.1 whereas in Scala 2 the list `elems`
4444
is filtered to retain only the elements of tuple type that match the pattern `(x, y)`.

docs/docs/reference/changed-features/pattern-matching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ precedence over _product-sequence match_.
8787
A usage of a variadic extractor is irrefutable if one of the following conditions holds:
8888

8989
- the extractor is used directly as a sequence match or product-sequence match
90-
- `U = Some[T]` (for Scala2 compatibility)
90+
- `U = Some[T]` (for Scala 2 compatibility)
9191
- `U <: R` and `U <: { def isEmpty: false }`
9292

9393
## Boolean Match

docs/docs/reference/contextual/context-functions-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ new scala.ContextFunctionN[T1, ..., Tn, T]:
5353

5454
A context parameter may also be a wildcard represented by an underscore `_`. In that case, a fresh name for the parameter is chosen arbitrarily.
5555

56-
Note: The closing paragraph of the
56+
**Note:** The closing paragraph of the
5757
[Anonymous Functions section](https://www.scala-lang.org/files/archive/spec/2.13/06-expressions.html#anonymous-functions)
5858
of Scala 2.13 is subsumed by context function types and should be removed.
5959

docs/docs/reference/contextual/derivation.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ inline def derived[A](using gen: K0.Generic[A]) as Eq[A] =
326326
The framework described here enables all three of these approaches without mandating any of them.
327327

328328
For a brief discussion on how to use macros to write a type class `derived`
329-
method please read more at [How to write a type class `derived` method using
330-
macros](./derivation-macro.md).
329+
method please read more at [How to write a type class `derived` method using macros](./derivation-macro.md).
331330

332331
### Deriving instances elsewhere
333332

@@ -353,7 +352,7 @@ ConstrApps ::= ConstrApp {‘with’ ConstrApp}
353352
| ConstrApp {‘,’ ConstrApp}
354353
```
355354

356-
Note: To align `extends` clauses and `derives` clauses, Scala 3 also allows multiple
355+
**Note:** To align `extends` clauses and `derives` clauses, Scala 3 also allows multiple
357356
extended types to be separated by commas. So the following is now legal:
358357

359358
```scala

docs/docs/reference/contextual/givens.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ a given for the type `Ord[Int]` whereas `listOrd[T]` defines givens
3333
for `Ord[List[T]]` for all types `T` that come with a given instance for `Ord[T]`
3434
themselves. The `using` clause in `listOrd` defines a condition: There must be a
3535
given of type `Ord[T]` for a given of type `Ord[List[T]]` to exist.
36-
Such conditions are expanded by the compiler to [context
37-
parameters](./using-clauses.md).
36+
Such conditions are expanded by the compiler to [context parameters](./using-clauses.md).
3837

3938
## Anonymous Givens
4039

@@ -98,7 +97,7 @@ transparent inline given mkAnnotations[A, T]: Annotations[A, T] = ${
9897
}
9998
```
10099

101-
Since `mkAnnotations` is `transparent`, the type of an application is the type of its right hand side, which can be a proper subtype of the declared result type `Annotations[A, T]`.
100+
Since `mkAnnotations` is `transparent`, the type of an application is the type of its right-hand side, which can be a proper subtype of the declared result type `Annotations[A, T]`.
102101

103102
## Pattern-Bound Given Instances
104103

@@ -167,5 +166,5 @@ of given instances:
167166

168167
- A _structural instance_ contains one or more types or constructor applications,
169168
followed by `with` and a template body that contains member definitions of the instance.
170-
- An _alias instance_ contains a type, followed by `=` and a right hand side expression.
169+
- An _alias instance_ contains a type, followed by `=` and a right-hand side expression.
171170
- An _abstract instance_ contains just the type, which is not followed by anything.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This definition effectively says that values of type `T` can (only) be
4343
compared to other values of type `T` when using `==` or `!=`. The definition
4444
affects type checking but it has no significance for runtime
4545
behavior, since `==` always maps to `equals` and `!=` always maps to
46-
the negation of `equals`. The right hand side `CanEqual.derived` of the definition
46+
the negation of `equals`. The right-hand side `CanEqual.derived` of the definition
4747
is a value that has any `CanEqual` instance as its type. Here is the definition of class
4848
`CanEqual` and its companion object:
4949

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Given instances can be mapped to combinations of implicit objects, classes and i
3838
```
3939

4040
3. Alias givens map to implicit methods or implicit lazy vals. If an alias has neither type nor context parameters,
41-
it is treated as a lazy val, unless the right hand side is a simple reference, in which case we can use a forwarder to
41+
it is treated as a lazy val, unless the right-hand side is a simple reference, in which case we can use a forwarder to
4242
that reference without caching it.
4343

4444
Examples:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def minimum[T](xs: List[T])(using Ord[T]) =
5959
maximum(xs)(using descending)
6060
```
6161

62-
The `minimum` method's right hand side passes `descending` as an explicit argument to `maximum(xs)`.
62+
The `minimum` method's right-hand side passes `descending` as an explicit argument to `maximum(xs)`.
6363
With this setup, the following calls are all well-formed, and they all normalize to the last one:
6464

6565
```scala

docs/docs/reference/features-classification.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: doc-page
3-
title: A Classification of Proposed Language Features
3+
title: "A Classification of Proposed Language Features"
44
date: April 6, 2019
55
author: Martin Odersky
66
---
@@ -52,7 +52,7 @@ These constructs replace existing constructs with the aim of making the language
5252

5353
With the exception of early initializers and old-style vararg patterns, all superseded constructs continue to be available in Scala 3.0. The plan is to deprecate and phase them out later.
5454

55-
Value classes (superseded by opaque type aliases) are a special case. There are currently no deprecation plans for value classes, since we might want to bring them back in a more general form if they are supported natively by the JVM as is planned by project Valhalla.
55+
Value classes (superseded by opaque type aliases) are a special case. There are currently no deprecation plans for value classes, since we might bring them back in a more general form if they are supported natively by the JVM as is planned by project Valhalla.
5656

5757
**Status: bimodal: now or never / can delay**
5858

@@ -121,7 +121,7 @@ Currently implemented features could stay around indefinitely. Updated docs may
121121
**Migration cost: moderate to high**
122122

123123
Dropped features require rewrites to avoid their use in programs. These rewrites can sometimes be automatic (e.g. for procedure syntax, symbol literals, auto application)
124-
and sometimes need to be manual (e.g. class shadowing, auto tupling). Sometimes the rewrites would have to be non-local, affecting use sites as well as definition sites (e.g., in the case of DelayedInit, unless we find a solution).
124+
and sometimes need to be manual (e.g. class shadowing, auto tupling). Sometimes the rewrites would have to be non-local, affecting use sites as well as definition sites (e.g., in the case of `DelayedInit`, unless we find a solution).
125125

126126
## Changes
127127

@@ -164,7 +164,7 @@ Being new features, existing code migrates without changes. To be sure, sometime
164164

165165
The following constructs together aim to put metaprogramming in Scala on a new basis. So far, metaprogramming was achieved by a combination of macros and libraries such as [Shapeless](https://github.com/milessabin/shapeless) that were in turn based on some key macros. Current Scala 2 macro mechanisms are a thin veneer on top the current Scala 2 compiler, which makes them fragile and in many cases impossible to port to Scala 3.
166166

167-
It's worth noting that macros were never included in the Scala 2 language specification and were so far made available only under an `-experimental` flag. This has not prevented their widespread usage.
167+
It's worth noting that macros were never included in the [Scala 2 language specification](https://scala-lang.org/files/archive/spec/2.13/) and were so far made available only under an `-experimental` flag. This has not prevented their widespread usage.
168168

169169
To enable porting most uses of macros, we are experimenting with the advanced language constructs listed below. These designs are more provisional than the rest of the proposed language constructs for Scala 3.0. There might still be some changes until the final release. Stabilizing the feature set needed for metaprogramming is our first priority.
170170

@@ -185,9 +185,7 @@ Existing macro libraries will have to be rewritten from the ground up. In many c
185185

186186
## Changes to Type Checking and Inference
187187

188-
The Scala 3 compiler uses a new algorithm for type inference, which relies on
189-
a general subtype constraint solver. The new algorithm often
190-
[works better than the old](https://contributors.scala-lang.org/t/better-type-inference-for-scala-send-us-your-problematic-cases/2410), but there are inevitably situations where the results of both algorithms differ, leading to errors diagnosed by Scala 3 for programs that the Scala 2 compiler accepts.
188+
The Scala 3 compiler uses a new algorithm for type inference, which relies on a general subtype constraint solver. The new algorithm often [works better than the old](https://contributors.scala-lang.org/t/better-type-inference-for-scala-send-us-your-problematic-cases/2410), but there are inevitably situations where the results of both algorithms differ, leading to errors diagnosed by Scala 3 for programs that the Scala 2 compiler accepts.
191189

192190
**Status: essential**
193191

@@ -197,6 +195,6 @@ The new type-checking and inference algorithms are the essential core of the new
197195

198196
Some existing programs will break and, given the complex nature of type inference, it will not always be clear what change caused the breakage and how to fix it.
199197

200-
In our experience, macros and changes in type and implicit argument inference together cause the large majority of problems encountered when porting existing code to Scala 3. The latter source of problems could be addressed systematically by a tool that added all inferred types and implicit arguments to a Scala 2 source code file. Most likely such a tool would be implemented as a Scala 2 compiler plugin. The resulting code would have a greatly increased likelihood to compile under Scala 3, but would often be bulky to the point of being unreadable. A second part of the rewriting tool should then selectively and iteratively remove type and implicit annotations that were synthesized by the first part as long as they compile under Scala 3. This second part could be implemented as a program that invokes the Scala 3 compiler `scalac` programmatically.
198+
In our experience, macros and changes in type and implicit argument inference together cause the large majority of problems encountered when porting existing code to Scala 3. The latter source of problems could be addressed systematically by a tool that added all inferred types and implicit arguments to a Scala 2 source code file. Most likely such a tool would be implemented as a [Scala 2 compiler plugin](https://docs.scala-lang.org/overviews/plugins/index.html). The resulting code would have a greatly increased likelihood to compile under Scala 3, but would often be bulky to the point of being unreadable. A second part of the rewriting tool should then selectively and iteratively remove type and implicit annotations that were synthesized by the first part as long as they compile under Scala 3. This second part could be implemented as a program that invokes the Scala 3 compiler `scalac` programmatically.
201199

202200
Several people have proposed such a tool for some time now. I believe it is time we find the will and the resources to actually implement it.

docs/docs/reference/metaprogramming/erased-terms-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ title: "Erased Terms Spec"
4343
if `def f(erased x: T): U` then `f: (erased T) => U`.
4444

4545

46-
5. Erasure Semantics
46+
5. Erasure semantics
4747
* All `erased` parameters are removed from the function
4848
* All argument to `erased` parameters are not passed to the function
4949
* All `erased` definitions are removed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ This type describes function values that take any argument `e` of type
3535
`Entry` and return a result of type `e.Key`.
3636

3737
Recall that a normal function type `A => B` is represented as an
38-
instance of the `Function1` trait (i.e. `Function1[A, B]`) and
39-
analogously for functions with more parameters. Dependent functions
38+
instance of the [`Function1` trait](https://dotty.epfl.ch/api/scala/Function1.html)
39+
(i.e. `Function1[A, B]`) and analogously for functions with more parameters. Dependent functions
4040
are also represented as instances of these traits, but they get an additional
4141
refinement. In fact, the dependent function type above is just syntactic sugar for
4242

docs/docs/reference/new-types/match-types.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Elem[List[Float]] =:= Float
2222
Elem[Nil.type] =:= Nothing
2323
```
2424

25-
Here `=:=` is understood to mean that left and right hand sides are mutually
25+
Here `=:=` is understood to mean that left and right-hand sides are mutually
2626
subtypes of each other.
2727

2828
In general, a match type is of the form
@@ -214,7 +214,8 @@ be caught and turned into a compile-time error that indicates a trace of the
214214
subtype tests that caused the overflow without showing a full stack trace.
215215

216216
## Variance Laws for Match Types
217-
NOTE: This section does not reflect the current implementation.
217+
218+
**Note:** This section does not reflect the current implementation.
218219

219220
Within a match type `Match(S, Cs) <: B`, all occurrences of type variables count
220221
as covariant. By the nature of the cases `Ci` this means that occurrences in

docs/docs/reference/new-types/type-lambdas-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ with types that satisfy these constraints. Likewise
9696
```scala
9797
opaque type O[X] = List[X]
9898
```
99-
`O` is known to be invariant (and not covariant, as its right hand side would suggest). On the other hand, a transparent alias
99+
`O` is known to be invariant (and not covariant, as its right-hand side would suggest). On the other hand, a transparent alias
100100
```scala
101101
type O2[X] = List[X]
102102
```

0 commit comments

Comments
 (0)