Skip to content

Commit 7902453

Browse files
authored
Merge pull request #6684 from dotty-staging/doc-fixes
Docs polishings
2 parents 44d1b74 + 115e2df commit 7902453

18 files changed

+49
-54
lines changed

docs/_includes/features.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ <h1 id="so-features">So, features?</h1>
2121
<td>Implemented</td>
2222
</tr>
2323
<tr>
24-
<td><a href="http://dotty.epfl.ch/docs/reference/contextual/query-types.html">Context query</a></td>
24+
<td><a href="http://dotty.epfl.ch/docs/reference/contextual/implicit-function-types.html">Context query</a></td>
2525
<td>Implemented</td>
2626
</tr>
2727
<tr>
2828
<td><a href="https://dotty.epfl.ch/docs/reference/other-new-features/trait-parameters.html">Trait parameters</a></td>
2929
<td>Implemented</td>
3030
</tr>
3131
<tr>
32-
<td><a href="https://dotty.epfl.ch/docs/reference/contextual/instance-defs.html">Implied Instances</a></td>
32+
<td><a href="https://dotty.epfl.ch/docs/reference/contextual/delegates.html">Implied Instances</a></td>
3333
<td>Implemented</td>
3434
</tr>
3535
<tr>
36-
<td><a href="https://dotty.epfl.ch/docs/reference/contextual/inferable-params.html">Inferable parameters</a></td>
36+
<td><a href="https://dotty.epfl.ch/docs/reference/contextual/given-clauses.html">Inferable parameters</a></td>
3737
<td>Implemented</td>
3838
</tr>
3939
<tr>

docs/blog/_posts/2019-03-05-13th-dotty-milestone-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ object B {
209209
```
210210

211211
**You can read more about** [implied
212-
imports](https://dotty.epfl.ch/docs/reference/contextual/import-implied.html)
212+
imports](https://dotty.epfl.ch/docs/reference/contextual/import-delegate.html)
213213
from the docs or the relevant PR
214214
[#5868](https://github.com/lampepfl/dotty/pull/5868).
215215

docs/blog/_posts/2019-04-15-14th-dotty-milestone-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ For more information, please see the [documentation](http://dotty.epfl.ch/docs/r
124124

125125
Some of the other changes include:
126126

127-
- `infer` method renamed to `the`, the semantics of which is now the same as that of the `the` method of Shapeless. Namely, the implicits are resolved more precisely – see this [gist](https://gist.github.com/milessabin/8833a1dbf7e8245b30f8) for an example in Shapeless, and the Dotty [documentation](http://dotty.epfl.ch/docs/reference/contextual/inferable-params.html#querying-implied-instances) for more details.
127+
- `infer` method renamed to `the`, the semantics of which is now the same as that of the `the` method of Shapeless. Namely, the implicits are resolved more precisely – see this [gist](https://gist.github.com/milessabin/8833a1dbf7e8245b30f8) for an example in Shapeless, and the Dotty [documentation](http://dotty.epfl.ch/docs/reference/contextual/given-clauses.html#querying-implied-instances) for more details.
128128
- The syntax of quoting and splicing was changed. Now the quoting is expressed via `'{ ... }` and `'[...]` and splicing – via `${...}` and `$id`. Please see the [documentation](http://dotty.epfl.ch/docs/reference/other-new-features/principled-meta-programming.html) for more details on these features.
129129

130130
# Let us know what you think!

docs/docs/reference/contextual/instance-defs.md renamed to docs/docs/reference/contextual/delegates.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Delegates"
44
---
55

66
Delegates define "canonical" values of certain types
7-
that serve for synthesizing arguments to [given clauses](./inferable-params.html). Example:
7+
that serve for synthesizing arguments to [given clauses](./given-clauses.html). Example:
88

99
```scala
1010
trait Ord[T] {
@@ -33,7 +33,7 @@ This code defines a trait `Ord` with two delegate definitions. `IntOrd` defines
3333
a delegate for the type `Ord[Int]` whereas `ListOrd[T]` defines delegates
3434
for `Ord[List[T]]` for all types `T` that come with a delegate for `Ord[T]` themselves.
3535
The `given` clause in `ListOrd` defines an implicit parameter.
36-
Given clauses are further explained in the [next section](./inferable-params.html).
36+
Given clauses are further explained in the [next section](./given-clauses.html).
3737

3838
## Anonymous Delegates
3939

@@ -59,6 +59,8 @@ returned for this and all subsequent accesses to `global`.
5959
Alias delegates can be anonymous, e.g.
6060
```scala
6161
delegate for Position = enclosingTree.position
62+
delegate for Context given (outer: Context) =
63+
outer.withOwner(currentOwner)
6264
```
6365
An alias delegate can have type parameters and given clauses just like any other delegate, but it can only implement a single type.
6466

docs/docs/reference/contextual/inferable-params.md renamed to docs/docs/reference/contextual/given-clauses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ call trees where the same value is passed over and over again in long call chain
99
functions. Given clauses can help here since they enable the compiler to synthesize
1010
repetitive arguments instead of the programmer having to write them explicitly.
1111

12-
For example, given the [delegates](./instance-defs.md) defined previously,
12+
For example, given the [delegates](./delegates.md) defined previously,
1313
a maximum function that works for any arguments for which an ordering exists can be defined as follows:
1414
```scala
1515
def max[T](x: T, y: T) given (ord: Ord[T]): T =
File renamed without changes.
File renamed without changes.

docs/docs/reference/contextual/query-types.md renamed to docs/docs/reference/contextual/implicit-function-types.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,14 @@ As a larger example, here is a way to define constructs for checking arbitrary p
117117
object PostConditions {
118118
opaque type WrappedResult[T] = T
119119

120-
def result[T] given (r: WrappedResult[T]): T = f
120+
def result[T] given (r: WrappedResult[T]): T = r
121121

122-
def (x: T) ensuring [T](condition: given WrappedResult[T] => Boolean): T = {
123-
delegate for WrappedResult[T] = x
124-
assert(condition)
125-
x
126-
}
122+
def (x: T) ensuring [T] (condition: given WrappedResult[T] => Boolean): T =
123+
assert(condition) given x
127124
}
125+
import PostConditions.{ensuring, result}
128126

129-
object Test {
130-
import PostConditions.{ensuring, result}
131-
val s = List(1, 2, 3).sum.ensuring(result == 6)
132-
}
127+
val s = List(1, 2, 3).sum.ensuring(result == 6)
133128
```
134129
**Explanations**: We use an implicit function type `given WrappedResult[T] => Boolean`
135130
as the type of the condition of `ensuring`. An argument to `ensuring` such as
@@ -151,4 +146,4 @@ as the best possible code one could write by hand:
151146
For more info, see the [blog article](https://www.scala-lang.org/blog/2016/12/07/implicit-function-types.html),
152147
(which uses a different syntax that has been superseded).
153148

154-
[More details](./query-types-spec.html)
149+
[More details](./implicit-function-types-spec.html)

docs/docs/reference/contextual/import-implied.md renamed to docs/docs/reference/contextual/import-delegate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ object Delegates {
4747
}
4848
```
4949
the import
50-
```
50+
```scala
5151
import delegate Delegates.{for Ordering[_], ExecutionContext}
5252
```
5353
would import the `intOrd`, `listOrd`, and `ec` delegates but leave out the `im` delegate, since it fits none of the specified bounds.
5454

5555
By-type imports can be mixed with by-name imports. If both are present in an import clause, by-type imports come last. For instance, the import clause
56-
```
56+
```scala
5757
import delegate Instances.{im, for Ordering[_]}
5858
```
5959
would import `im`, `intOrd`, and `listOrd` but leave out `ec`. By-type imports cannot be mixed with a wildcard import in the same import clause.

docs/docs/reference/contextual/motivation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ Existing Scala programmers by and large have gotten used to the status quo and s
4747

4848
The following pages introduce a redesign of contextual abstractions in Scala. They introduce four fundamental changes:
4949

50-
1. [Delegates](./instance-defs.html) are a new way to define basic terms that can be synthesized. They replace implicit definitions. The core principle of the proposal is that, rather than mixing the `implicit` modifier with a large number of features, we have a single way to define terms that can be synthesized for types.
50+
1. [Delegates](./delegates.html) are a new way to define basic terms that can be synthesized. They replace implicit definitions. The core principle of the proposal is that, rather than mixing the `implicit` modifier with a large number of features, we have a single way to define terms that can be synthesized for types.
5151

52-
2. [Given Clauses](./inferable-params.html) are a new syntax for implicit _parameters_ and their _arguments_. Both are introduced with the same keyword, `given`. This unambiguously aligns parameters and arguments, solving a number of language warts. It also allows us to have several implicit parameter sections, and to have implicit parameters followed by normal ones.
52+
2. [Given Clauses](./given-clauses.html) are a new syntax for implicit _parameters_ and their _arguments_. Both are introduced with the same keyword, `given`. This unambiguously aligns parameters and arguments, solving a number of language warts. It also allows us to have several implicit parameter sections, and to have implicit parameters followed by normal ones.
5353

54-
3. [Delegate Imports](./import-implied.html) are a new class of imports that specifically import delegates and nothing else. Delegates _must be_ imported with `import delegate`, a plain import will no longer bring them into scope.
54+
3. [Delegate Imports](./import-delegate.html) are a new class of imports that specifically import delegates and nothing else. Delegates _must be_ imported with `import delegate`, a plain import will no longer bring them into scope.
5555

5656
4. [Implicit Conversions](./conversions.html) are now expressed as delegates of a standard `Conversion` class. All other forms of implicit conversions will be phased out.
5757

@@ -63,8 +63,8 @@ This section also contains pages describing other language features that are rel
6363
- [Typeclass Derivation](./derivation.html) introduces constructs to automatically derive typeclass delegates for ADTs.
6464
- [Multiversal Equality](./multiversal-equality.html) introduces a special typeclass
6565
to support type safe equality.
66-
- [Implicit Function Types](./query-types.html) provide a way to abstract over given clauses.
67-
- [Implicit By-Name Parameters](./inferable-by-name-parameters.html) are an essential tool to define recursive synthesized values without looping.
66+
- [Implicit Function Types](./implicit-function-types.html) provide a way to abstract over given clauses.
67+
- [Implicit By-Name Parameters](./implicit-by-name-parameters.html) are an essential tool to define recursive synthesized values without looping.
6868
- [Relationship with Scala 2 Implicits](./relationship-implicits.html) discusses the relationship between old-style implicits and new-style delegates and given clauses and how to migrate from one to the other.
6969

7070
Overall, the new design achieves a better separation of term inference from the rest of the language: There is a single way to define delegates instead of a multitude of forms all taking an `implicit` modifier. There is a single way to introduce implicit parameters and arguments instead of conflating implicit with normal arguments. There is a separate way to import delegates that does not allow them to hide in a sea of normal imports. And there is a single way to define an implicit conversion which is clearly marked as such and does not require special syntax.

0 commit comments

Comments
 (0)