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

Add alphanumeric equivalents to symbolic operators? #315

Open
danxmoran opened this issue May 3, 2019 · 1 comment
Open

Add alphanumeric equivalents to symbolic operators? #315

danxmoran opened this issue May 3, 2019 · 1 comment

Comments

@danxmoran
Copy link
Contributor

Rho makes heavy use of symbolic operators and extension methods for syntax:

"description" ** route
Map("oauth" -> List("admin")) ^^ route
route >>> headerDecoders
route |>> { () => doThing }
// Proposed in #314:
List("tag1", "tag2") @@ route

My team (relatively new to Scala) sees this syntax as the biggest pain-point of using Rho, to the point that we ended up defining our own syntax extensions:

implicit class BuilderOps[HL <: HList](val builder: PathBuilder[IO, HL]) extends AnyVal {
  def withDescription(description: String): PathBuilder[IO, HL] =
    new PathBuilder(
      builder.method,
      PathAST.MetaCons(builder.path, RouteDesc(description))
    )
}

implicit class RouteOps[F[_], T <: HList](val route: RouteExecutable[F, T]) extends AnyVal {
  def bindAction[U, R](action: U)(implicit hltf: HListToFunc[F, T, U], srvc: CompileRoutes[F, R]): R = route |>> action
}

Would there be interest in adding alphanumeric methods like these to the main Rho types? I'm thinking we could do something like the new collections did, and:

  1. Add methods with descriptive names to the builder classes
  2. For backwards-compat, change the existing symbolic operators to call the new alphanumeric methods
@zarthross
Copy link
Member

zarthross commented May 3, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants