Skip to content

Commit

Permalink
move Liskov.isa method to LiskovInstances
Browse files Browse the repository at this point in the history
for implicit priority. prepare dotty

```
scala> implicitly[scalaz.Liskov[Int, Int]]
1 |implicitly[scalaz.Liskov[Int, Int]]
  |                                   ^
  |According to new implicit resolution rules, this will be ambiguous:
  |both method isa in object Liskov and method refl in object Liskov match type scalaz.Liskov[Int, Int]
val res0: scalaz.Liskov[Int, Int] = scalaz.Liskov$$anon$2@25022628
```
  • Loading branch information
xuwei-k committed May 16, 2020
1 parent 662e704 commit c65027c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/src/main/scala/scalaz/Liskov.scala
Expand Up @@ -30,6 +30,12 @@ sealed abstract class LiskovInstances {

def compose[A, B, C](bc: B <~< C, ab: A <~< B): (A <~< C) = trans(bc, ab)
}

/** Lift Scala's subtyping relationship */
implicit def isa[A, B >: A]: A <~< B = new (A <~< B) {
def substCo[F[+ _]](p: F[A]) = p
def substCt[F[- _]](p: F[B]) = p
}
}

object Liskov extends LiskovInstances {
Expand All @@ -40,12 +46,6 @@ object Liskov extends LiskovInstances {
/** A flipped alias, for those used to their arrows running left to right */
type >~>[+B, -A] = Liskov[A, B]

/** Lift Scala's subtyping relationship */
implicit def isa[A, B >: A]: A <~< B = new (A <~< B) {
def substCo[F[+ _]](p: F[A]) = p
def substCt[F[- _]](p: F[B]) = p
}

/** We can witness equality by using it to convert between types */
implicit def witness[A, B](lt: A <~< B): A => B = {
type f[-X] = X => B
Expand Down

0 comments on commit c65027c

Please sign in to comment.