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

Given search doesn't work with identical polymorphic function types #22921

Open
p-pavel opened this issue Apr 6, 2025 · 1 comment
Open

Given search doesn't work with identical polymorphic function types #22921

p-pavel opened this issue Apr 6, 2025 · 1 comment
Labels
area:implicits related to implicits itype:bug

Comments

@p-pavel
Copy link

p-pavel commented Apr 6, 2025

Compiler version

3.3.x, 3.4.x, 3.5.x, 3.6.x, probably earlier too

Minimized code

//> using scala 3.6.4
type TF1[Lang[_]] = [A] => Lang[A] ?=> A
type TF2[Lang[_]] = [A] => Lang[A] ?=> A
type TF3[Lang[_]] = TF1[Lang]

trait IsTF[T]
given [T[_]] => IsTF[TF1[T]] = new IsTF {}

trait Abc[A]:
  def plus(a: A, b: A): A

val s1 = summon[TF1[Abc] =:= TF2[Abc]] // Ok
val s2 = summon[TF1[Abc] =:= ([A] => Abc[A] ?=> A)] //Ok
val t1 = summon[IsTF[ TF1[Abc]]] //Ok
val t2 = summon[IsTF[ [A] => Abc[A] ?=> A ]] //Not found
val t3 = summon[IsTF[ TF2[Abc]]] // Not found
val t4 = summon[IsTF[ TF3[Abc]]] // Ok

Output

No given instance of type IsTF[[A] => (x$1: Abc[A]) ?=> A] was found for parameter x of method summon in object Predef
No given instance of type IsTF[TF2[Abc]] was found for parameter x of method summon in object Predef

Expectation

given instances should be found

@p-pavel p-pavel added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 6, 2025
@p-pavel
Copy link
Author

p-pavel commented Apr 6, 2025

the workaround I used (it's not a general workaround, because I specify the Algebra):

trait IsTF[T[_], A]

given [T[_], A] => (A =:= TF1[T]) => IsTF[T,A] = ....

Compiler is able to find the instance for TF2[T] and derive the proof that TF2[T] =:= TF1[T]

@Gedochao Gedochao added area:implicits related to implicits and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:implicits related to implicits itype:bug
Projects
None yet
Development

No branches or pull requests

2 participants