Created
March 12, 2013 09:45
-
-
Save szeiger/5141613 to your computer and use it in GitHub Desktop.
This file contains 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
trait Rep { | |
type Base | |
} | |
class Query[E] extends Rep { self => | |
type C[_] <: Iterable[_] | |
type Base = C[E] | |
def map[F](f: E => F): Query[F] { type C[X] = self.C[X] } = ??? | |
def to[D[_] <: Iterable[_]]: Query[E] { type C[X] = D[X] } = ??? | |
} | |
object Query { | |
def apply[D[_] <: Iterable[_], T]: Query[T] { type C[X] = D[X] } = ??? | |
} | |
def run[E](q: Rep { type Base = E }): E = ??? | |
def elem[E](q: Query[E]): E = ??? | |
val q1 = Query[Vector, Int] | |
val q2 = q1.map(_.toString).to[Set] | |
val r = run(q2) | |
val rt: Set[String] = r | |
val r2 = elem(q2) | |
val r2t: String = r2 |
This file contains 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
trait Rep[T] | |
class Query[C[_], E] extends Rep[C[E]] { self => | |
def map[F](f: E => F): Query[C, F] = ??? | |
def to[D[_] <: Iterable[_]]: Query[D, E] = ??? | |
} | |
object Query { | |
def apply[D[_] <: Iterable[_], T]: Query[D, T] = ??? | |
} | |
def run[E](q: Rep[E]): E = ??? | |
def elem[E](q: Query[X, E] forSome { type X[_] }): E = ??? | |
val q1 = Query[Vector, Int] | |
val q2 = q1.map(_.toString).to[Set] | |
val r = run(q2) | |
val rt: Set[String] = r | |
val r2 = elem(q2) | |
val r2t: String = r2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment