Skip to content

Type missmatch errors #172

@kaffepanna

Description

@kaffepanna

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions