Created
October 25, 2017 00:35
-
-
Save thsutton/e05719d8cda48ad59f9d21bfc39d87e6 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 Queries { | |
type K | |
trait Query { | |
def from(k: K): Query | |
} | |
def select(where: String) = Select(where) | |
def scan() = Scan() | |
case class Select(where: String, private val from: Option[K] = None) { | |
def from(k: K): Select = copy(from=Some(k)) | |
} | |
case class Scan(private val from: Option[K] = None) { | |
def from(k: K): Scan = copy(from=Some(k)) | |
} | |
} | |
case class Table[K, V](name: String) extends Queries | |
object Foo { | |
val table = Table[String, Int]("aTable") | |
val q = table.scan() | |
val next = Some("x") | |
val f1 = next.map(q.from) | |
val f2 = next.map(q.from _) | |
val f3 = next.map(q.from(_)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment