-
-
Save doytsujin/57e173bd0f825da706a37851900af4a1 to your computer and use it in GitHub Desktop.
proxy.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mapmap | |
trait ECtx | |
trait KCtx | |
trait Var[C, T] { | |
def get(c: C): T | |
} | |
trait EVar[T] extends Var[ECtx, T] | |
trait KVar[T] extends Var[KCtx, T] { | |
def range(c: KCtx, vStart: Int, vStop: Int): Traversable[T] | |
} | |
trait Proc[C <: Proxy] { | |
val proxy: C | |
def switch: proxy.v[Boolean] | |
} | |
trait Proxy { | |
type Ctx | |
type v[X] <: Var[Ctx, X] | |
} | |
trait EProxy extends Proxy { | |
def ectx: ECtx | |
type Ctx = ECtx | |
} | |
object test { | |
def eTest[C <: EProxy](p: Proc[C], c: C) { | |
p.switch.get(c.ectx) | |
} | |
/// above compile ok until here | |
trait KProxy extends Proxy { | |
def kctx: KCtx | |
type Ctx = KCtx | |
type v[X] <: KVar[X] | |
// ouch! this doesn't compile | |
} | |
def kTest[C <: KProxy](p: Proc[C], c: C) { | |
p.switch.get(c.kctx) | |
p.switch.range(c.kctx, 1, 2) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment