Created
December 18, 2015 14:50
-
-
Save potix2/9b8f7291fbdfa83ea062 to your computer and use it in GitHub Desktop.
[WIP]tagless final
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
//SEE: http://keens.github.io/slide/DSLtoTagless_Final/ | |
case class Result | |
case class JSON | |
trait ScenarioSYM[T] { | |
def get(url: String): ScenarioSYM[T] | |
def post(url: Sting, data: JSON): ScenarioSYM[T] | |
def and(first: ScenarioSYM[T], second: ScenarioSYM[T]): ScenarioSYM[T] | |
def run(scenario: ScenariosSYM[T]): ScenarioSYM[T] | |
} | |
object ScenarioSYM { | |
def run[T: ScenarioSYM](scenario: ScenarioSYM[T], user: String)(implicit s: ScenarioSYM[T]) = { | |
} | |
def get[A: ScenarioSYM](url: String): ScenarioSYM[A] = implicitly[ScenarioSYM[A]].get(url) | |
def post[A: ScenarioSYM](url: String, data: JSON): ScenarioSYM[A] = implicitly[ScenarioSYM[A]].post(url, data) | |
def and[A: ScenarioSYM](first: ScenarioSYM[A], second: ScenarioSYM[A]): ScenarioSYM[A] = implicitly[ScenarioSYM[A]].and(first, second) | |
implicit val runResult = new ScenarioSYM[String] { | |
def get(url: String): ScenarioSYM[String] = s"get $url" | |
def post(url: Sting, data: JSON): ScenarioSYM[String] = s"post $url" | |
def and(first: ScenarioSYM[String], second: ScenarioSYM[String]): ScenarioSYM[String] = | |
run(first) | |
} | |
def main = { | |
val scenario = and( | |
get("/"), | |
post("/update")) | |
run(scenario, "user") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment