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 missing constructors to ContextRoutes #7123
Conversation
Added some useful constructors to ContextRoutes that existed on HttpRoutes.
63fca36
to
1092c52
Compare
* fixup some docs
1092c52
to
21d7a6a
Compare
a759e95
to
4459251
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating over this! Despite my minor comment, this looks good to me
*/ | ||
def local[T, F[_]: Monad](f: ContextRequest[F, T] => ContextRequest[F, T])( | ||
fa: ContextRoutes[T, F] | ||
): ContextRoutes[T, F] = Kleisli(req => Monad[OptionT[F, *]].unit >> fa.run(f(req))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm missing something, but do we need here flatmapping over F[Unit]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is similar to Http.local
– i.e. deferring without the Defer
constraint per se.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thank you. I rather meant, is this a thing actually (in this particular use-case)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't know if the effect within the Kleisli fa
is deferred, so this is just to make sure it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it all about awareness of whether the F
has eager semantics of computation?
4459251
to
4f3e4e8
Compare
Co-authored-by: Daniel Esik <e.danicheg@yandex.ru>
4f3e4e8
to
0a66f72
Compare
Added some useful constructors to ContextRoutes that existed on HttpRoutes.