Open
Description
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:
- Add methods with descriptive names to the builder classes
- For backwards-compat, change the existing symbolic operators to call the new alphanumeric methods
Metadata
Assignees
Labels
No labels