-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put implicit support for evidence from predef types (#3508)
* Put implicit support for evidence from predef types * fix format * get tests passing
- Loading branch information
Showing
8 changed files
with
85 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package cats.evidence | ||
|
||
private[evidence] trait AsSupport { | ||
|
||
/** | ||
* In 2.13 there is a method on ev that makes this safe. | ||
* But lack of this method does not make the cast unsafe | ||
* it just makes it not provable without the cast. | ||
*/ | ||
@inline implicit def asFromPredef[A, B](implicit ev: A <:< B): A As B = | ||
As.refl[A].asInstanceOf[A As B] | ||
} |
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,12 @@ | ||
package cats.evidence | ||
|
||
private[evidence] trait IsSupport { | ||
|
||
/** | ||
* In 2.13 there is a method on ev that makes this safe. | ||
* But lack of this method does not make the cast unsafe | ||
* it just makes it not provable without the cast. | ||
*/ | ||
@inline implicit def isFromPredef[A, B](implicit ev: A =:= B): A Is B = | ||
Is.refl[A].asInstanceOf[A Is B] | ||
} |
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 @@ | ||
package cats.evidence | ||
|
||
private[evidence] trait AsSupport { | ||
@inline implicit def asFromPredef[A, B](implicit ev: A <:< B): A As B = { | ||
// we need F to be covariant, and the type lambda loses that | ||
// if we write As[A, ?] | ||
type F[+Z] = As[A, Z] | ||
ev.substituteCo[F](As.refl[A]) | ||
} | ||
} |
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,6 @@ | ||
package cats.evidence | ||
|
||
private[evidence] trait IsSupport { | ||
@inline implicit def isFromPredef[A, B](implicit ev: A =:= B): A Is B = | ||
ev.substituteCo[Is[A, *]](Is.refl[A]) | ||
} |
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
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
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
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