Skip to content

Commit 91d7724

Browse files
committed
Add propositions raised in the Friday meeting.
1 parent b4ab9fc commit 91d7724

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

docs/_docs/internals/cc/alternatives-to-sealed.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ A capture checking variant
77

88
- We now treat all type variables as sealed (so no special `sealed` modifier is necessary anymore). A type variable cannot be instantiated to a type that contains a covariant occurrence of `cap`. The same restriction applies to the types of mutable variables and try expressions.
99

10+
- For any immutable variable `x`, introduce a _reach_ capability `x*` which stands for
11+
"all capabilities reachable through `x`". We have `{x} <: {x*} <: dcs(x)}` where the deep capture set `dcs(x)` of `x`
12+
is the union of all capture sets that appear in covariant position in the type of `x`. If `x` and `y` are different
13+
variables then `{x*}` and `{y*}` are unrelated.
14+
1015
- We modify the VAR rule as follows:
1116

1217
x: T in E
@@ -106,6 +111,10 @@ But this works:
106111
def cons(x: Proc, xs: Set[Proc]): Set[() ->{x,xs*} Unit] =
107112
Set.include[() ->{x,xs*} Unit](x, xs) // ok
108113
```
114+
Say we have `a: () ->{io} Unit` and `as: List[() ->{io} Unit]`. Then `cons(a, as)`
115+
is of type `() ->{a, as*} Unit`, which is a subtype of `() ->{io} Unit`. This follows from
116+
`{a} <: {io}` by rule (Var) and `{as*} <: dcs(as) = {io}` by the subcapturing rules for
117+
reach capabilities.
109118

110119
This also works:
111120
```scala
@@ -133,7 +142,7 @@ def mapCompose[A](ps: List[(A => A, A => A)]): List[A ->{ps*} A] =
133142
// The closure is widened to the non-dependent function type
134143
// (f: A ->{ps*} A, g: A ->{ps*} A) -> A ->{ps*} A
135144
```
136-
But it does no work with `compose2``, since the type variable of `map` cannot be instantiated to `A => A`.`
145+
But it does not work with `compose2`, since the type variable of `map` cannot be instantiated to `A => A`.
137146

138147
Syntax Considerations:
139148

@@ -150,9 +159,9 @@ Work items:
150159
- internal representation: maybe have a synthetic private member `*` of
151160
`Any` to which `x*` maps, i.e. `x*` is `x.*`. Advantage: maps like substitutions
152161
and asSeenFrom work out of the box.
153-
- subcapturing: `x <:< x*`.
162+
- subcapturing: `x <:< x* <: dcs(x)`.
154163
- Narrowing code: in `adaptBoxed` where `x.type` gets widened to `T^{x}`, also
155164
do the covariant `cap` to `x*` replacement.
156165
- Drop local roots
157-
- Drop sealed scheme.
166+
- Make all type paraneters sealed
158167

0 commit comments

Comments
 (0)