typedapi icon indicating copy to clipboard operation
typedapi copied to clipboard

Get rid of `:= :>`

Open pheymann opened this issue 7 years ago • 4 comments

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]

pheymann avatar Feb 28 '18 15:02 pheymann

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 := :>.

pheymann avatar Mar 01 '18 11:03 pheymann

That's interesting. I wish I had the time to look further into this case and try to make it work.

gvolpe avatar Mar 03 '18 04:03 gvolpe

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.

pheymann avatar Mar 03 '18 12:03 pheymann

I will keep that issue open until both of us agree that we cannot find a proper solution :)

pheymann avatar Mar 25 '18 19:03 pheymann