Skip to content

Instantly share code, notes, and snippets.

@potix2
Created December 18, 2015 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save potix2/9b8f7291fbdfa83ea062 to your computer and use it in GitHub Desktop.
Save potix2/9b8f7291fbdfa83ea062 to your computer and use it in GitHub Desktop.
[WIP]tagless final
//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