-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51d8cab
commit 8f0f13c
Showing
4 changed files
with
64 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
trait A | ||
trait B | ||
|
||
trait Covariant[F[+_]] { | ||
trait G[+X] | ||
|
||
def fx: F[A & B] = fy | ||
def fy: F[A] & F[B] = fx | ||
|
||
def gx: G[A & B] = gy | ||
def gy: G[A] & G[B] = gx | ||
} | ||
|
||
trait Contravariant[F[-_]] { | ||
trait G[-X] | ||
|
||
def fx: F[A | B] = fy | ||
def fy: F[A] & F[B] = fx | ||
|
||
def gx: G[A | B] = gy | ||
def gy: G[A] & G[B] = gx | ||
} | ||
|
||
trait LiskovViolation[F[+_]] { | ||
trait A { def children: F[A] } | ||
trait B { def children: F[B] } | ||
trait C extends A with B { def children: F[A] & F[B] = ??? } | ||
|
||
def fc1: C = new C {} | ||
def fc2: A & B = fc1 | ||
|
||
def fy1: F[A & B] = fc1.children | ||
def fy2: F[A & B] = fc2.children | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
object InfiniteSubtypingLoopPossibility { | ||
trait A[X] | ||
trait B extends A[B] | ||
trait Min[+S <: B with A[S]] | ||
|
||
def c: Any = ??? | ||
c match { | ||
case pc: Min[_] => | ||
} | ||
} |