According to this question Spray uses sbt-boilerplate to generate ApplyConverter
instances that implicitly convert A :: B :: ... :: HNil => R
to the more traditional (A, B, ...) => R
for ease of use. That question was asked over a year ago; can this now be done using, for example, macros or Shapeless's newer functionality so that an external code generation step isn't required?
Is there a boilerplate-free way to convert HLists to an argument list?
174 views Asked by Jonathan Chow AtThere are 2 answers
I think there is no way to do this in pure Scala, as there is no way to generically talk about the FunctionN
interfaces. At the macro level it would be possible, but not in a way that makes use of the AST representation available; a macro to do this would probably be reduced to (effectively) doing string manipulation - in which case there's very little advantage over sbt-boilerplate.
Even if it did become possible, Spray is a fairly foundational library that needs to be usable in conjunction with other libraries (thus it continues to build releases against old versions of Scala and Akka) - something that will only become more important if and when Play is ported to run on top of Spray. So I would expect it will be a while before Spray introduces a hard dependency on Shapeless 2 (which is incompatible with Shapeless 1), and until then I imagine they'll try and keep the code for the shapeless2 build of spray-routing as close as possible to that for the shapeless1 build for ease of maintenance.
This has been included in shapeless for a very long time. In shapeless 2.0.0 you can do the following,
(REPL result type rendering tidied for readability).