You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Play framework (and probably others?) it's common to have a higher-order action that does some processing, and conditionally delegates to another action.
pseudo-code examples:
// reads some parameters from the request and call a delegate// with derived parameters or with derived + original parametersdefsecure(d: Request=>Response):Request=>ResponsedefwithUser(d: User=>Response):Request=>ResponsedefwithUser2(d: User=>Request=>Response):Request=>ResponsedefwithUserOrElse(d: User=>Request=>Response, orElse: =>Response):Request=>Response
which check some properties on the Request and either continue with f or return some error.
(Related to #51)
// extracts two parameters from the request and passes them to a delegate, // which may use other parameters from the requestdefpaged[A:EncodeJson](d: Request=> (Offset,MaxResults) =>A):Request=>Response=
req => d(req)(req.queryParams[Offset]("paging_offset"),
req.queryParams[MaxResults]("paging_max"),
).asJson
From what I can tell, in rho, the F needs to accept all of the parameters on the HList stack, making it difficult to modularize things like this.
Can I write an F that pushes / pops some arguments from the stack, and pass the remainder to another F? Or how can I get some kind of modularity here?
The text was updated successfully, but these errors were encountered:
Ultimately you can only get nice function composition with Function1. Besides getting path related values, there is no reason you can't just use a Request => Response and extract the query and header params the neutral way as is done in http4s proper. Of course, whos not going to want path variables?
There is no way to pop parameters off the stack, but it should be doable if we want to put the work into it. That is basically how parboiled2 works. However, I personally don't see this as a high priority for me in the near term.
In Play framework (and probably others?) it's common to have a higher-order action that does some processing, and conditionally delegates to another action.
pseudo-code examples:
which check some properties on the Request and either continue with
f
or return some error.(Related to #51)
From what I can tell, in rho, the
F
needs to accept all of the parameters on theHList
stack, making it difficult to modularize things like this.Can I write an
F
that pushes / pops some arguments from the stack, and pass the remainder to anotherF
? Or how can I get some kind of modularity here?The text was updated successfully, but these errors were encountered: