Skip to content

Instantly share code, notes, and snippets.

@tomaszperek
Created October 10, 2015 11:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaszperek/d5987363d1f36c5c591f to your computer and use it in GitHub Desktop.
Save tomaszperek/d5987363d1f36c5c591f to your computer and use it in GitHub Desktop.
Naive quasispray directive
trait Directive[X <: HList] { self =>
def happly(f: X => Route): Route
def apply[F](f: F)(implicit fp: FnToProduct.Aux[F, X => Route]) = {
happly(fp(f))
}
def &[Y <: HList](that: Directive[Y])(implicit prepend: Prepend[X, Y]): Directive[prepend.Out] = new Directive[prepend.Out] {
override def happly(f: prepend.Out => Route): Route = {
self.happly( x =>
that.happly( y =>
f(prepend(x, y))
)
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment