-
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
Refactor of Context instance hierarchy #383
Conversation
trait ContextInstances[TC[f[_], r] >: WithContext[f, r]] extends LocalInstances[TC] | ||
|
||
/** lightweight version of ApplicativeLocal | ||
* consider to use `WithLocal` or `In` for better type inference |
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.
* consider to use `WithLocal` or `In` for better type inference | |
* consider using `WithLocal` or `In` for better type inference |
BTW, type In[C, F[_]] = WithContext[F, C]
doesn't seem to be a proper alternative for Local
, does it?
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.
Yes, an artifact of hasty copypasta
type HasContext[F[_], C] = Context[F] { type Ctx = C } | ||
|
||
type HasLocal[F[_], C] = Local[F] { type Ctx = C } | ||
|
||
type HasProvide[F[_], G[_], C] = Provide[F] { type Ctx = C; type Lower[A] = G[A] } | ||
|
||
type HasContextRun[F[_], G[_], C] = RunContext[F] { type Ctx = C; type Lower[A] = G[A] } | ||
type HasContextRun[F[_], G[_], C] = RunContext[F] { type Lower[A] = G[A]; type Ctx = C; } |
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.
Does this swap affect inference anyhow? Why hasn't HasProvide been changed?
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.
No, this change is insignificant. Just a scar of searching how to make ReaderT
instance work inside ContextBase
companion
@@ -3,13 +3,15 @@ import cats.{ApplicativeError, MonadError} | |||
import cats.data.Ior | |||
|
|||
package object tofu { | |||
type In[C, F[_]] = WithContext[F, C] |
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.
What's the use?
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.
Just small type alias to write X In F
instead of F WithContext X
def apply[F[_]](implicit ctx: RunContext[F]): HasContextRun[F, ctx.Lower, ctx.Ctx] = ctx | ||
type Aux[F[_], G[_], C] = HasContextRun[F, G, C] | ||
|
||
final implicit def readerTContext[F[_]: Applicative, C]: HasContextRun[ReaderT[F, C, *], F, C] = |
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.
So we still can't avoid this even with Kai's approach?
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.
Yes, unfortunately, scala reject to search parent companions for Aux-types with lifted higher-kinded type-members.
So, removing this and Provide
's one makes ContextSuite fail
} | ||
|
||
/** a mix-in for supplying environment data type companions with useful things */ | ||
trait Companion[C] { |
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.
Usage examples?
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.
- usage examples
No description provided.