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

add possibility to use → in route pattern, in addition to -> #2109

Merged
merged 2 commits into from Sep 24, 2018

Conversation

Projects
None yet
4 participants
@fsarradin
Contributor

fsarradin commented Sep 24, 2018

No description provided.

add possibility to use → in route pattern, in addition to ->
XXX: due to infix operation precedence, → has a lower priority than /.
     So you have to use parentheses in pattern matching when using this
     operator.
@fsarradin

This comment has been minimized.

Contributor

fsarradin commented Sep 24, 2018

XXX: due to infix operation precedence, → has a lower priority than /. So you have to use parentheses in pattern matching when using this operator.

So this works

  case GET  (Root / "test.json") =>

And, this won't

  case GET  Root / "test.json" =>

It gives you something like this

constructor cannot be instantiated to expected type;
 found   : org.http4s.dsl.impl./
 required: org.http4s.Request[cats.effect.IO]
        case GET → Root / "test.json" => true
@rossabaker

This comment has been minimized.

Member

rossabaker commented Sep 24, 2018

Do you still like the feature, given the limitation?

@fsarradin

This comment has been minimized.

Contributor

fsarradin commented Sep 24, 2018

Yes, cause on another I use a rule to rewrite -> into . And, in a sense, parentheses help to have a better delimitation between method and path 😊

@rossabaker

If you're on the 0.18 series, we could retarget this for release-0.18.x and get it in a patch sooner. Otherwise, we can target this for the 0.19 series.

👍 after we add a note to that operator.

@@ -17,6 +17,7 @@ trait Http4sDsl[F[_]] extends Http4s with Methods with Statuses with Responses[F
val :? : impl.:?.type = impl.:?
val ~ : impl.~.type = impl.~
val -> : impl.->.type = impl.->
val : impl.->.type = impl.->

This comment has been minimized.

@rossabaker

rossabaker Sep 24, 2018

Member

I'd put a scaladoc on this to note the precedence issue. It's obvious when you mention it, but I didn't think about it beforehand.

@fsarradin

This comment has been minimized.

Contributor

fsarradin commented Sep 24, 2018

scaladoc added.

And I'm currently using the 0.19 series :)

@rossabaker rossabaker added this to the 0.19.0-M3 milestone Sep 24, 2018

@rossabaker

👍 Thanks!

@jmcardon jmcardon merged commit 0da0ec1 into http4s:master Sep 24, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment