Skip to content

Commit 82046e7

Browse files
committed
Use explicit Top bounds for boxmap example
Can be reverted once we assume type variables have by default a {*} Any upper bound.
1 parent dcd5bdf commit 82046e7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/pos-custom-args/captures/boxmap-paper.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
infix type ==> [A, B] = (A => B) retains *
1+
type Top = {*} Any retains *
2+
infix type ==> [A, B] = {*} (A => B)
23

3-
type Cell[+T] = [K] => (T ==> K) => K
4+
type Cell[+T <: Top] = [K] => (T ==> K) => K
45

5-
def cell[T](x: T): Cell[T] =
6+
def cell[T <: Top](x: T): Cell[T] =
67
[K] => (k: T ==> K) => k(x)
78

8-
def get[T](c: Cell[T]): T = c[T](identity)
9+
def get[T <: Top](c: Cell[T]): T = c[T](identity)
910

10-
def map[A, B](c: Cell[A])(f: A ==> B): Cell[B]
11+
def map[A <: Top, B <: Top](c: Cell[A])(f: A ==> B): Cell[B]
1112
= c[Cell[B]]((x: A) => cell(f(x)))
1213

13-
def pureMap[A, B](c: Cell[A])(f: A => B): Cell[B]
14+
def pureMap[A <: Top, B <: Top](c: Cell[A])(f: A => B): Cell[B]
1415
= c[Cell[B]]((x: A) => cell(f(x)))
1516

16-
def lazyMap[A, B](c: Cell[A])(f: A ==> B): {f} () => Cell[B]
17+
def lazyMap[A <: Top, B <: Top](c: Cell[A])(f: A ==> B): {f} () => Cell[B]
1718
= () => c[Cell[B]]((x: A) => cell(f(x)))
1819

1920
trait IO:
@@ -32,7 +33,7 @@ def test(io: {*} IO) =
3233

3334
val r = lazyMap[{io} () => Int, Unit](c)(f => g(f))
3435
val r2 = lazyMap[{io} () => Int, Unit](c)(g)
35-
// val r3 = lazyMap(c)(g)
36+
val r3 = lazyMap(c)(g)
3637
val _ = r()
3738
val _ = r2()
38-
// val _ = r3()
39+
val _ = r3()

0 commit comments

Comments
 (0)