File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ [31m-- [E007] Type Mismatch Error: boxmap.scala:15:2 -------------------------------[0m
2
+ [31m15 |[0m () => b[[35mBox[B][0m](([36mx[0m: [35mA[0m) => box(f(x)))
3
+ | [31m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[0m
4
+ | Found: ([1m[31m([0m) => Box[B][1m[31m)[0m[1m[31m [0m[1m[31mretains[0m[1m[31m [0m[1m[31mb[0m[1m[31m [0m[1m[31mretains[0m[1m[31m [0m[1m[31mf[0m
5
+ | Required: () => Box[B]
6
+ |
7
+ | where: B is a type in [33mmethod[0m [35mlazymap[0m with bounds <: Top
8
+
9
+ longer explanation available when compiling with `-explain`
10
+ 1 error found
Original file line number Diff line number Diff line change
1
+ type Top = Any retains *
2
+ class Cap extends Retains [* ]
3
+
4
+ infix type ==> [A , B ] = (A => B ) retains *
5
+
6
+ type Box [+ T <: Top ] = [K <: Top ] => (T ==> K ) => K
7
+
8
+ def box [T <: Top ](x : T ): Box [T ] =
9
+ [K <: Top ] => (k : T ==> K ) => k(x)
10
+
11
+ def map [A <: Top , B <: Top ](b : Box [A ])(f : A ==> B ): Box [B ] =
12
+ b[Box [B ]]((x : A ) => box(f(x)))
13
+
14
+ def lazymap [A <: Top , B <: Top ](b : Box [A ])(f : A ==> B ): () => Box [B ] =// retains b.type | f.type =
15
+ () => b[Box [B ]]((x : A ) => box(f(x)))
Original file line number Diff line number Diff line change
1
+ type Top = Any retains *
2
+ class Cap extends Retains [* ]
3
+
4
+ infix type ==> [A , B ] = (A => B ) retains *
5
+
6
+ type Box [+ T <: Top ] = [K <: Top ] => (T ==> K ) => K
7
+
8
+ def box [T <: Top ](x : T ): Box [T ] =
9
+ [K <: Top ] => (k : T ==> K ) => k(x)
10
+
11
+ def map [A <: Top , B <: Top ](b : Box [A ])(f : A ==> B ): Box [B ] =
12
+ b[Box [B ]]((x : A ) => box(f(x)))
13
+
14
+ def lazymap [A <: Top , B <: Top ](b : Box [A ])(f : A ==> B ): (() => Box [B ]) retains b.type | f.type =
15
+ () => b[Box [B ]]((x : A ) => box(f(x)))
16
+
17
+ def test [A <: Top , B <: Top ] =
18
+ def lazymap [A <: Top , B <: Top ](b : Box [A ])(f : A ==> B ) =
19
+ () => b[Box [B ]]((x : A ) => box(f(x)))
20
+ val x : (b : Box [A ]) => (f : A ==> B ) => (() => Box [B ]) retains b.type | f.type = lazymap[A , B ]
21
+ ()
You can’t perform that action at this time.
0 commit comments