Skip to content
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

Inconsistent use of def vs val in embedded typeclass #264

Closed
ghostdogpr opened this issue Oct 6, 2020 · 0 comments · Fixed by #478
Closed

Inconsistent use of def vs val in embedded typeclass #264

ghostdogpr opened this issue Oct 6, 2020 · 0 comments · Fixed by #478

Comments

@ghostdogpr
Copy link

In Ask:

def applicative: Applicative[F]

In Censor:

val applicative: Applicative[F]

So if you define traits that extend both, like:

trait MyTrait[F[_], Env, Evt]  extends Censor[F, Chain[Evt]] with Ask[F, Env]
trait MyTrait2[F[_], Env, Evt] extends Ask[F, Env] with Censor[F, Chain[Evt]]

The order becomes important. MyTrait2 compiles but MyTrait fails with:

stable, immutable value required to override:
[error] val applicative: cats.Applicative[F] (defined in trait Censor)
[error]   with def applicative: cats.Applicative[F] (defined in trait Ask)
[error]   trait MyTrait[F[_], Env, Evt] extends Censor[F, Chain[Evt]] with Ask[F, Env]

How about using the same pattern to avoid such issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant