Skip to content

Commit d3433a6

Browse files
authored
Merge pull request #6681 from tegonal/docs
[Docs] consistent use of subscripts, link to sections
2 parents 154506a + caaa6de commit d3433a6

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ layout: doc-page
33
title: "Dependent Function Types - More Details"
44
---
55

6-
Initial implementation in (#3464)[https://github.com/lampepfl/dotty/pull/3464].
6+
Initial implementation in [#3464](https://github.com/lampepfl/dotty/pull/3464)
77

88
## Syntax
99

1010
FunArgTypes ::= InfixType
1111
| ‘(’ [ FunArgType {‘,’ FunArgType } ] ‘)’
12-
| '(' TypedFunParam {',' TypedFunParam } ')'
13-
TypedFunParam ::= id ':' Type
12+
| ‘(’ TypedFunParam {',' TypedFunParam } ‘)’
13+
TypedFunParam ::= id ‘:’ Type
1414

1515
Dependent function types associate to the right, e.g.
1616
`(s: S) ⇒ (t: T) ⇒ U` is the same as `(s: S) ⇒ ((t: T) ⇒ U)`.
@@ -39,9 +39,9 @@ documentation](https://dotty.epfl.ch/docs/reference/dropped-features/limit22.htm
3939

4040
## Examples
4141

42-
- (depfuntype.scala)[https://github.com/lampepfl/dotty/blob/0.10.x/tests/pos/depfuntype.scala]
42+
- [depfuntype.scala](https://github.com/lampepfl/dotty/blob/master/tests/pos/depfuntype.scala)
4343

44-
- (eff-dependent.scala)[https://github.com/lampepfl/dotty/blob/0.10.x/tests/run/eff-dependent.scala]
44+
- [eff-dependent.scala](https://github.com/lampepfl/dotty/blob/master/tests/run/eff-dependent.scala)
4545

4646
### Type Checking
4747

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ if `Ci = [Xs] => P => T` and there are minimal instantiations `Is` of the type v
7474
T' = [Xs := Is] T
7575
```
7676
An instantiation `Is` is _minimal_ for `Xs` if all type variables in `Xs` that appear
77-
covariantly and nonvariantly in `Is` are as small as possible and all type variables in `Xs` that appear contravariantly in `Is` are as large as possible. Here, "small" and "large" are understood wrt `<:`.
77+
covariantly and nonvariantly in `Is` are as small as possible and all type variables in `Xs` that appear contravariantly in `Is` are as large as possible. Here, "small" and "large" are understood with respect to `<:`.
7878

7979
For simplicity, we have omitted constraint handling so far. The full formulation of subtyping tests describes them as a function from a constraint and a pair of types to
8080
either _success_ and a new constraint or _failure_. In the context of reduction, the subtyping test `S <: [Xs := Is] P` is understood to leave the bounds of all variables
@@ -88,20 +88,20 @@ if
8888
```
8989
Match(S, C1, ..., Cn) can-reduce i, T
9090
```
91-
and, for `j` in `1..i-1`: `C_j` is disjoint from `C_i`, or else `S` cannot possibly match `C_j`.
92-
See the section on overlapping patterns for an elaboration of "disjoint" and "cannot possibly match".
91+
and, for `j` in `1..i-1`: `Cj` is disjoint from `Ci`, or else `S` cannot possibly match `Cj`.
92+
See the section on [overlapping patterns](#overlapping-patterns) for an elaboration of "disjoint" and "cannot possibly match".
9393

9494
## Subtyping Rules for Match Types
9595

9696
The following rules apply to match types. For simplicity, we omit environments and constraints.
9797

9898
The first rule is a structural comparison between two match types:
9999
```
100-
Match(S, C1, ..., Cn) <: Match(T, D1, ..., Dm)
100+
Match(S, C1, ..., Cm) <: Match(T, D1, ..., Dn)
101101
```
102102
` `if
103103
```
104-
S <: T, m <= n, Ci <: Di for i in 1..n
104+
S <: T, m >= n, Ci <: Di for i in 1..n
105105
```
106106
I.e. scrutinees and corresponding cases must be subtypes, no case re-ordering is allowed, but the subtype can have more cases than the supertype.
107107

@@ -160,7 +160,7 @@ Assuming this extension, we can then try to typecheck as usual. E.g. to typechec
160160

161161
Typechecking the second case hits a snag, though. In general, the assumption `x.type <: B` is not enough to prove that
162162
`M[x.type]` reduces to `2`. However we can reduce `M[x.type]` to `2` if the types `A` and `B` do not overlap.
163-
So correspondence of match terms to match types is feasible only in the case of non-overlapping patterns.
163+
So correspondence of match terms to match types is feasible only in the case of non-overlapping patterns (see next section about [overlapping patterns](#overlapping-patterns))
164164

165165
For simplicity, we have disregarded the `null` value in this discussion. `null` does not cause a fundamental problem but complicates things somewhat because some forms of patterns do not match `null`.
166166

@@ -172,10 +172,10 @@ A complete defininition of when two patterns or types overlap still needs to be
172172
- A final class `C` overlaps with a trait `T` only if `C` extends `T` directly or indirectly.
173173
- A class overlaps with a sealed trait `T` only if it overlaps with one of the known subclasses of `T`.
174174
- An abstract type or type parameter `A` overlaps with a type `B` only if `A`'s upper bound overlaps with `B`.
175-
- A union type `A_1 | A_2` overlaps with `B` only if `A_1` overlaps with `B` or `A_2` overlaps with `B`.
176-
- An intersection type `A_1 & A_2` overlaps with `B` only if both `A_1` and `A_2` overlap with `B`.
177-
- If `C[X_1, ..., X_n]` is a case class, then the instance type `C[A_1, ..., A_n]` overlaps with the instance type `C[B_1, ..., B_n]` only if for every index `i` in `1..n`,
178-
if `X_i` is the type of a parameter of the class, then `A_i` overlaps with `B_i`.
175+
- A union type `A1 | ... | An` overlaps with `B` only if at least one of `Ai` for `i` in `1..n` overlaps with `B`.
176+
- An intersection type `A1 & ... & An` overlaps with `B` only if all of `Ai` for `i` in `1..n` overlap with `B`.
177+
- If `C[X1, ..., Xn]` is a case class, then the instance type `C[A1, ..., An]` overlaps with the instance type `C[B1, ..., Bn]` only if for every index `i` in `1..n`,
178+
if `Xi` is the type of a parameter of the class, then `Ai` overlaps with `Bi`.
179179

180180
The last rule in particular is needed to detect non-overlaps for cases where the scrutinee and the patterns are tuples. I.e. `(Int, String)` does not overlap `(Int, Int)` since
181181
`String` does not overlap `Int`.

0 commit comments

Comments
 (0)