Created
August 1, 2024 09:21
-
-
Save kubukoz/a1425d62d522ff256560ca8592f8a2fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using option -Ykind-projector | |
trait Demo { | |
type LA | |
type LB | |
type RA | |
type RB | |
def x(using | |
laEqLb: LA =:= LB, | |
raEqRb: RA =:= RB | |
): (LA => RA) =:= (LB => RB) = { | |
// start with just proof that the function itself is equivalent to itself | |
// and then substitute parts step-by-step | |
val base: (LA => RA) =:= (LA => RA) = summon[(LA => RA) =:= (LA => RA)] | |
// replace LA in rhs | |
val step1: (LA => RA) =:= (LB => RA) = | |
laEqLb.substituteCo[[A] =>> (LA => RA) =:= (A => RA)](base) | |
// replace RA in rhs | |
val step2: (LA => RA) =:= (LB => RB) = | |
raEqRb.substituteCo[[A] =>> (LA => RA) =:= (LB => A)](step1) | |
step2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment