-
Notifications
You must be signed in to change notification settings - Fork 95
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
Support for WithContext
structure promotion added to Context.Companion
#473
Conversation
WithContext
structure promotion added to `Context.Compa…WithContext
structure promotion added to Context.Companion
type Has[F[_]] = WithContext[F, C] | ||
|
||
implicit def tofuPromoteContextStructure[F[_], A](implicit | ||
implicit def promoteContextStructure[F[_], A](implicit |
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 think the priorities are wrong. WithLocal
as a more concrete instance should be higher, and WithContext
- lower.
Can you write a summon test?
22db4a4
to
8f97c7f
Compare
type Has[F[_]] = WithContext[F, C] | ||
|
||
implicit def tofuPromoteContextStructure[F[_], A](implicit | ||
abstract class WithContextOpaque[F[_], C0] extends WithContext[F, C0] |
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.
Why did you make it an inner class? It could be a concrete high-level class, as we usually do in tofu:
class WithContextContains[F[_], C, A](implicit wc: WithContext[F, C], field: C Contains A)
extends WithContext[F, A] {
private val wa = wc.extract(field)
def functor: Functor[F] = wa.functor
def context: F[A] = wa.context
}
And then in trait.
implicit def promoteContextStructure[F[_], A](implicit withContext: WithContext[F, C],
field: C Contains A
): WithContextContains[F, C, A] =
new WithContextContains[F, C, A]
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.
@catostrophe, my bad, we'd better keep style consistent.
…nion` + summon tests.
8f97c7f
to
fbc36d3
Compare
No description provided.