Skip to content

Commit d0e4615

Browse files
committed
Tweaks to wordings in docs
Also: drop some doc pages that are no longer used.
1 parent d53867c commit d0e4615

10 files changed

+37
-173
lines changed

docs/docs/reference/contextual/context-bounds.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ A context bound is a shorthand for expressing a common pattern of an inferable p
99
```scala
1010
def maximum[T: Ord](xs: List[T]): T = xs.reduceLeft(max)
1111
```
12-
A bound like `: Ord` on a type parameter `T` of a method or class indicates an inferred parameter `given Ord[T]`. The inferred parameter(s) generated from context bounds come last in the definition of the containing method or class. E.g.,
13-
```
12+
A bound like `: Ord` on a type parameter `T` of a method or class indicates an inferable parameter `given Ord[T]`. The inferable parameter(s) generated from context bounds come last in the definition of the containing method or class. E.g.,
13+
```scala
1414
def f[T: C1 : C2, U: C3](x: T) given (y: U, z: V): R
1515
```
1616
would expand to
17-
```
17+
```scala
1818
def f[T, U](x: T) given (y: U, z: V) given C1[T], C2[T], C3[U]: R
1919
```
2020
Context bounds can be combined with subtype bounds. If both are present, subtype bounds come first, e.g.
21-
```
21+
```scala
2222
def g[T <: B : C](x: T): R = ...
2323
```
2424

docs/docs/reference/contextual/conversions.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
22
layout: doc-page
3-
title: "Implied Conversions"
3+
title: "Inferable Conversions"
44
---
55

66
Inferable conversions are defined by implied instances of the `scala.Conversion` class.
77
This class is defined in package `scala` as follows:
88
```scala
99
abstract class Conversion[-T, +U] extends (T => U)
1010
```
11-
For example, here is an implied conversion from `String` to `Token`:
11+
For example, here is an inferable conversion from `String` to `Token`:
1212
```scala
1313
implied for Conversion[String, Token] {
1414
def apply(str: String): Token = new KeyWord(str)
1515
}
1616
```
17-
An implied conversion is applied automatically by the compiler in three situations:
17+
An inferable conversion is applied automatically by the compiler in three situations:
1818

1919
1. If an expression `e` has type `T`, and `T` does not conform to the expression's expected type `S`.
2020
2. In a selection `e.m` with `e` of type `T`, but `T` defines no member `m`.

docs/docs/reference/contextual/implicit-conversions.md

-78
This file was deleted.

docs/docs/reference/contextual/inferable-params.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ The `infer` method is simply defined as the identity function over an inferable
9494
```scala
9595
def infer[T] given (x: T) = x
9696
```
97-
Functions like `infer` that have only inferable parameters are also called implicit _queries_.
97+
Functions like `infer` that have only inferable parameters are also called _context queries_.
9898

9999
## Syntax
100100

docs/docs/reference/contextual/query-types-spec.md

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
---
22
layout: doc-page
3-
title: "Query Types - More Details"
3+
title: "Context Query Types - More Details"
44
---
55

6-
Initial implementation in (#1775)[https://github.com/lampepfl/dotty/pull/1775].
7-
86
## Syntax
97

108
Type ::= ...
119
| `given' FunArgTypes `=>' Type
1210
Expr ::= ...
1311
| `given' FunParams `=>' Expr
1412

15-
Query types associate to the right, e.g.
13+
Context query types associate to the right, e.g.
1614
`given S => given T => U` is the same as `given S => (given T => U)`.
1715

1816
## Implementation
1917

20-
Query types are shorthands for class types that define `apply`
18+
Context query types are shorthands for class types that define `apply`
2119
methods with inferable parameters. Specifically, the `N`-ary function type
2220
`T1, ..., TN => R` is a shorthand for the class type
2321
`ImplicitFunctionN[T1 , ... , TN, R]`. Such class types are assumed to have the following definitions, for any value of `N >= 1`:
@@ -27,10 +25,10 @@ trait ImplicitFunctionN[-T1 , ... , -TN, +R] {
2725
def apply given (x1: T1 , ... , xN: TN): R
2826
}
2927
```
30-
Query types erase to normal function types, so these classes are
28+
Context query types erase to normal function types, so these classes are
3129
generated on the fly for typechecking, but not realized in actual code.
3230

33-
Query literals `given (x1: T1, ..., xn: Tn) => e` map
31+
Context query literals `given (x1: T1, ..., xn: Tn) => e` map
3432
inferable parameters `xi` of types `Ti` to a result given by expression `e`.
3533
The scope of each implicit parameter `xi` is `e`. The parameters must have pairwise distinct names.
3634

@@ -55,18 +53,17 @@ abbreviated to `given x => e`.
5553
An inferable parameter may also be a wildcard represented by an underscore `_`. In
5654
that case, a fresh name for the parameter is chosen arbitrarily.
5755

58-
Note: The closing paragraph of the [Anonymous Functions section](https://www
59-
.scala-lang.org/files/archive/spec/2.12/06-expressions.html#anonymous-
60-
functions) of the Scala 2.12 is subsumed by query types and should
61-
be removed.
56+
Note: The closing paragraph of the
57+
[Anonymous Functions section](https://www.scala-lang.org/files/archive/spec/2.12/06-expressions.html#anonymous-functions)
58+
of Scala 2.12 is subsumed by query types and should be removed.
6259

6360
Query literals `given (x1: T1, ..., xn: Tn) => e` are
6461
automatically created for any expression `e` whose expected type is
6562
`scala.ImplicitFunctionN[T1, ..., Tn, R]`, unless `e` is
6663
itself a query literal. This is analogous to the automatic
6764
insertion of `scala.Function0` around expressions in by-name argument position.
6865

69-
Query types generalize to `N > 22` in the same way that function types do, see [the corresponding
66+
Context query types generalize to `N > 22` in the same way that function types do, see [the corresponding
7067
documentation](https://dotty.epfl.ch/docs/reference/dropped-features/limit22.html).
7168

7269
## Examples
@@ -79,4 +76,4 @@ Gist](https://gist.github.com/OlivierBlanvillain/234d3927fe9e9c6fba074b53a7bd9
7976

8077
### Type Checking
8178

82-
After desugaring no additional typing rules are required for query types.
79+
After desugaring no additional typing rules are required for context query types.

docs/docs/reference/contextual/query-types.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
22
layout: doc-page
3-
title: "First Class Queries"
3+
title: "Context Queries"
44
---
55

6-
In the context of inference, _queries_ are functions with inferable parameters.
7-
_Query types_ are the types of first-class queries. Example:
6+
_Context queries_ are functions with inferable parameters.
7+
_Context query types_ are the types of first-class context queries.
8+
Here is an example for a context query type:
89
```scala
910
type Contextual[T] = given Context => T
1011
```
11-
A value of query type is applied to inferred arguments, in
12+
A value of context query type is applied to inferred arguments, in
1213
the same way a method with inferable parameters is applied. For instance:
1314
```scala
1415
implied ctx for Context = ...
@@ -18,9 +19,9 @@ the same way a method with inferable parameters is applied. For instance:
1819
f(2) given ctx // explicit argument
1920
f(2) // argument is inferred
2021
```
21-
Conversely, if the expected type of an expression `E` is a query
22+
Conversely, if the expected type of an expression `E` is a context query
2223
type `given (T_1, ..., T_n) => U` and `E` is not already a
23-
query literal, `E` is converted to a query literal by rewriting to
24+
context query literal, `E` is converted to a context query literal by rewriting to
2425
```scala
2526
given (x_1: T1, ..., x_n: Tn) => E
2627
```
@@ -31,7 +32,7 @@ are available as implied instances in `E`.
3132
Like query types, query literals are written with a `given` prefix. They differ from normal function literals in two ways:
3233

3334
1. Their parameters are inferable.
34-
2. Their types are query types.
35+
2. Their types are context query types.
3536

3637
For example, continuing with the previous definitions,
3738
```scala
@@ -45,7 +46,7 @@ For example, continuing with the previous definitions,
4546
```
4647
### Example: Builder Pattern
4748

48-
Query types have considerable expressive power. For
49+
Context query types have considerable expressive power. For
4950
instance, here is how they can support the "builder pattern", where
5051
the aim is to construct tables like this:
5152
```scala
@@ -111,7 +112,7 @@ With that setup, the table construction code above compiles and expands to:
111112
```
112113
### Example: Postconditions
113114

114-
As a larger example, here is a way to define constructs for checking arbitrary postconditions using `ensuring` so that the checked result can be referred to simply by `result`. The example combines opaque aliases, query types, and extension methods to provide a zero-overhead abstraction.
115+
As a larger example, here is a way to define constructs for checking arbitrary postconditions using `ensuring` so that the checked result can be referred to simply by `result`. The example combines opaque aliases, context query types, and extension methods to provide a zero-overhead abstraction.
115116

116117
```scala
117118
object PostConditions {
@@ -136,7 +137,7 @@ object Test {
136137
val s = List(1, 2, 3).sum.ensuring(result == 6)
137138
}
138139
```
139-
**Explanations**: We use a query type `given WrappedResult[T] => Boolean`
140+
**Explanations**: We use a context query type `given WrappedResult[T] => Boolean`
140141
as the type of the condition of `ensuring`. An argument to `ensuring` such as
141142
`(result == 6)` will therefore have an implied instance of type `WrappedResult[T]` in
142143
scope to pass along to the `result` method. `WrappedResult` is a fresh type, to make sure

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Relationship with Scala 2 Implicits"
66
Many, but not all, of the new contextual abstraction features in Scala 3 can be mapped to Scala 2's implicits.
77
This page gives a rundown on the relationships between new and old features.
88

9-
# Simulating Contextual Abstraction with Implicits
9+
## Simulating Contextual Abstraction with Implicits
1010

1111
### Implied Instance Definitions
1212

@@ -109,7 +109,7 @@ Implicit function types have no analogue in Scala 2.
109109

110110
Implicit by-name parameters are not supported in Scala 2, but can be emulated to some degree by the `Lazy` type in Shapeless.
111111

112-
# Simulating Scala 2 in Dotty
112+
## Simulating Scala 2 in Dotty
113113

114114
### Implicit Conversions
115115

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

-56
This file was deleted.

docs/docs/reference/dropped-features/limit22.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ layout: doc-page
33
title: Dropped: Limit 22
44
---
55

6-
The limit of 22 for the maximal number of parameters of function types
7-
has been dropped. Functions can now have an arbitrary number of
6+
The limits of 22 for the maximal number of parameters of function types
7+
and the maximal number of fields in tuple types have been dropped.
8+
9+
Functions can now have an arbitrary number of
810
parameters. Functions beyond Function22 are represented with a new trait
911
`scala.FunctionXXL`.
1012

11-
The limit of 22 for the size of tuples is about to be dropped. Tuples
12-
will in the future be represented by an HList-like structure which can
13-
be arbitrarily large.
13+
Tuples can also have an arbitrary number of fields. Furthermore, they support generic operation such as concatenation and indexing.

docs/sidebar.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ sidebar:
5252
url: docs/reference/contextual/typeclasses.html
5353
- title: Typeclass Derivation
5454
url: docs/reference/derivation.html
55-
- title: Query Types
55+
- title: Context Queries
5656
url: docs/reference/contextual/query-types.html
5757
- title: Implied Conversions
5858
url: docs/reference/contextual/conversions.html

0 commit comments

Comments
 (0)