Add alphanumeric equivalents to symbolic operators?
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
I am not opposed to adding some aliases to help reduce confusion. Personally I like the symbolic operators for their compactness, but I understand it's not for everyone. I would happily accept a PR for this.
On Fri, May 3, 2019, 9:24 AM Daniel Moran [email protected] wrote:
Rho makes heavy use of symbolic operators and extension methods for syntax:
"description" ** routeMap("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 https://github.com/scala/collection-strawman/pull/57, and:
- Add methods with descriptive names to the builder classes
- For backwards-compat, change the existing symbolic operators to call the new alphanumeric methods
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/http4s/rho/issues/315, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIPMKBR7KKP5VTD4YTNVF3PTRDJFANCNFSM4HKULUVA .