typedapi
typedapi copied to clipboard
Get rid of `:= :>`
I had to use some initial empty state to guarantee that "path" is translated into a Witness. Why? Because an extension of String using implicit class was not able to derive a Witness, as Scala/Shapeless is not able to proof that the given String is a literal/singleton.
Another way could be to change the associativity (:>: instead of :>) and create GetCons, PutCons, ... as initial states with an empty HList type. Thus, we should be able to write:
val Api = "find" :>: Segment[String]('name) :>: Get[User]
I just remembered the problem I ran into when I tried that before:
"find" :>: Get[User]
// desugared
val x$1 = "find"
Get[User].:>:(mkWitness[x$1.type](x$1.asInstanceOf[x$1.type]))
Here Shapeless cannot find a Witness. Only:
Get[User].:>:("find")
// desugared
Get[User].:>:(mkWitness[String("find")]("find"))
will work which isn't a solution.
We have to keep := :>.
That's interesting. I wish I had the time to look further into this case and try to make it work.
I tried it for a while but stopped eventually as I also just have very limited time and this is more of a minor / cosmetic issue.
Maybe you find some time in the future to have a look, find a solution for it and open a PR :).
And thanks for your interest in this project.
I will keep that issue open until both of us agree that we cannot find a proper solution :)