simulacrum icon indicating copy to clipboard operation
simulacrum copied to clipboard

Type missmatch errors

Open kaffepanna opened this issue 6 years ago • 0 comments

After playing around a bit with simulacrum i have seen a few weird (maybe) behaviours

@typeclass trait TestClass[S[_]] {
  def test[P[_], I](a1: S[P[I]]): I
}

Works.

Adding second argument to test

@typeclass trait TestClass2[S[_]] {
 def test[P[_], I](a1: S[P[I]], x: I): I
}

results in:

type mismatch;
found   : S[P[I]]
required: S[P[Any]]
@typeclass trait TestClass2[S[_]] {

Going back to the first example. Lets add a Constraint on P[_]

  @typeclass trait TestClass3[S[_]] {
    def test[P[_]: Foldable, I](a1: S[P[I]]): I
  }

also works. So lets add a constraint on I

  @typeclass trait TestClass4[S[_]] {
    def test[P[_]: Foldable, I: Eq](a1: S[P[I]]): I
  }

results in:

 found   : cats.Eq[A]
    (which expands to)  cats.kernel.Eq[A]
 required: cats.Eq[I]
    (which expands to)  cats.kernel.Eq[I]
  @typeclass trait TestClass4[S[_]] {

Is this the desired behaviour?

kaffepanna avatar Jan 07 '20 21:01 kaffepanna