Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of := :> #2

Open
pheymann opened this issue Feb 28, 2018 · 4 comments
Open

Get rid of := :> #2

pheymann opened this issue Feb 28, 2018 · 4 comments
Labels
UX user experience (dal, api)

Comments

@pheymann
Copy link
Owner

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 pheymann added the enhancement New feature or request label Feb 28, 2018
@pheymann pheymann changed the title Get rid of := :> to define APIs Get rid of := :> Feb 28, 2018
@pheymann
Copy link
Owner Author

pheymann commented Mar 1, 2018

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 pheymann closed this as completed Mar 1, 2018
@gvolpe
Copy link

gvolpe commented Mar 3, 2018

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

@pheymann
Copy link
Owner Author

pheymann commented Mar 3, 2018

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
Copy link
Owner Author

pheymann commented Mar 25, 2018

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

@pheymann pheymann reopened this Mar 25, 2018
@pheymann pheymann added UX user experience (dal, api) and removed enhancement New feature or request labels Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX user experience (dal, api)
Projects
None yet
Development

No branches or pull requests

2 participants