You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_docs/reference/changed-features/eta-expansion-spec.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ implicit val bla: Double = 1.0
51
51
valbar= foo // val bar: Int => Float = ...
52
52
```
53
53
54
-
## Automatic Eta-Expansion and query types
54
+
## Automatic Eta-Expansion and context types
55
55
56
56
A method with context parameters can be expanded to a value of a context type by writing the expected context type explicitly.
57
57
@@ -66,7 +66,7 @@ val bar: Double ?=> Float = foo(3)
66
66
- If `m` is has an empty argument list (i.e. has type `()R`):
67
67
1. If the expected type is of the form `() => T`, we eta expand.
68
68
2. If m is defined by Java, or overrides a Java defined method, we insert `()`.
69
-
3. Otherwise we issue an error of the form:
69
+
3. Otherwise we issue an error of the form:`method must be called with () argument`
70
70
71
71
Thus, an unapplied method with an empty argument list is only converted to a function when a function type is expected. It is considered best practice to either explicitly apply the method to `()`, or convert it to a function with `() => m()`.
Copy file name to clipboardExpand all lines: docs/_docs/reference/changed-features/main-functions.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ final class happyBirthday:
72
72
caseerror: CLP.ParseError=>CLP.showError(error)
73
73
```
74
74
75
-
**Note**: The `<static>` modifier above expresses that the `main` method is generated
75
+
**Note:** The `<static>` modifier above expresses that the `main` method is generated
76
76
as a static method of class `happyBirthday`. It is not available for user programs in Scala. Regular "static" members are generated in Scala using objects instead.
77
77
78
78
[`@main`](https://scala-lang.org/api/3.x/scala/main.html) methods are the recommended scheme to generate programs that can be invoked from the command line in Scala 3. They replace the previous scheme to write program as objects with a special `App` parent class. In Scala 2, `happyBirthday` could be written also like this:
Copy file name to clipboardExpand all lines: docs/_docs/reference/contextual/givens.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,9 @@ that serve for synthesizing arguments to [context parameters](./using-clauses.md
10
10
```scala
11
11
traitOrd[T]:
12
12
defcompare(x: T, y: T):Int
13
-
extension (x: T) def< (y: T) = compare(x, y) <0
14
-
extension (x: T) def> (y: T) = compare(x, y) >0
13
+
extension (x: T)
14
+
def< (y: T) = compare(x, y) <0
15
+
def> (y: T) = compare(x, y) >0
15
16
16
17
givenintOrd:Ord[Int] with
17
18
defcompare(x: Int, y: Int) =
@@ -51,7 +52,7 @@ given [T](using Ord[T]): Ord[List[T]] with
51
52
If the name of a given is missing, the compiler will synthesize a name from
52
53
the implemented type(s).
53
54
54
-
**Note** The name synthesized by the compiler is chosen to be readable and reasonably concise. For instance, the two instances above would get the names:
55
+
**Note:** The name synthesized by the compiler is chosen to be readable and reasonably concise. For instance, the two instances above would get the names:
55
56
56
57
```scala
57
58
given_Ord_Int
@@ -62,7 +63,7 @@ The precise rules for synthesizing names are found [here](./relationship-implici
62
63
given instances of types that are "too similar". To avoid conflicts one can
63
64
use named instances.
64
65
65
-
**Note** To ensure robust binary compatibility, publicly available libraries should prefer named instances.
66
+
**Note:** To ensure robust binary compatibility, publicly available libraries should prefer named instances.
Copy file name to clipboardExpand all lines: docs/_docs/reference/contextual/type-classes.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ given Functor[List] with
82
82
x.map(f) // List already has a `map` method
83
83
```
84
84
85
-
With this `given` instance in scope, everywhere a `Functor` is expected, the compiler will accept a `List` to be used.
85
+
With this `given` instance in scope, everywhere a type with a `Functor` context bound is expected, the compiler will accept a `List` to be used.
86
86
87
87
For instance, we may write such a testing method:
88
88
@@ -214,7 +214,7 @@ instead of
214
214
show(compute(i)(config))(config)
215
215
```
216
216
217
-
Let's define this m then. First, we are going to define a type named `ConfigDependent` representing a function that when passed a `Config` produces a `Result`.
217
+
Let's define this `flatMap` then. First, we are going to define a type named `ConfigDependent` representing a function that when passed a `Config` produces a `Result`.
Copy file name to clipboardExpand all lines: docs/_docs/reference/experimental/canthrow.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,7 +124,7 @@ try
124
124
body
125
125
catch ...
126
126
```
127
-
Note that the right-hand side of the synthesized given is `???` (undefined). This is OK since
127
+
Note that the right-hand side of the synthesized given is `compiletime.erasedValue`. This is OK since
128
128
this given is erased; it will not be executed at runtime.
129
129
130
130
**Note 1:** The [`saferExceptions`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$experimental$$saferExceptions$.html) feature is designed to work only with checked exceptions. An exception type is _checked_ if it is a subtype of
0 commit comments