0

I fail to see how spray's directives correspond to continuation passing style (CPS).

More specifically, a continuation is (a -> r) -> r (in Haskell), but I cannot find where is this type ((a -> r) -> r) when using spray directives (which have the type of Route->Route where type Route = RequestContext => Unit).

Nor Route->Route neither type Route = RequestContext => Unit do resemble (a -> r) -> r, so how do directives relate to CPS ?

Could someone show how spray's directive correspond to continuation passing style ?

jhegedus
  • 20,244
  • 16
  • 99
  • 167

1 Answers1

0

A directive, in its simplest form, is defined as

abstract class Directive[L <: HList] {
  def happly(f: L => Route): Route
}

which is exactly a (a -> r) -> r. What you see in spray directives documentation is a high-level DSL which builds Directive instances under the hood. You can see the full definition in Directive.scala

Mustafa Simav
  • 1,019
  • 5
  • 6