-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compute mirror child types of a union
- Loading branch information
1 parent
16ed844
commit 65a0d8c
Showing
2 changed files
with
71 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
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,43 @@ | ||
import deriving.Mirror | ||
|
||
sealed trait Box[T] | ||
object Box | ||
|
||
case class Child[T](t: T) extends Box[T] | ||
|
||
object MirrorK1: | ||
type Of[F[_]] = Mirror { type MirroredType[A] = F[A] } | ||
|
||
def testSums = | ||
|
||
val foo = summon[Mirror.Of[Option[Int] | Option[String]]] | ||
summon[foo.MirroredElemTypes =:= (None.type, Some[Int] | Some[String])] | ||
|
||
val bar = summon[Mirror.Of[Box[Int] | Box[String]]] | ||
summon[bar.MirroredElemTypes =:= ((Child[Int] | Child[String]) *: EmptyTuple)] | ||
|
||
val qux = summon[Mirror.Of[Option[Int | String]]] | ||
summon[qux.MirroredElemTypes =:= (None.type, Some[Int | String])] | ||
|
||
val bip = summon[Mirror.Of[Box[Int | String]]] | ||
summon[bip.MirroredElemTypes =:= (Child[Int | String] *: EmptyTuple)] | ||
|
||
val bap = summon[MirrorK1.Of[[X] =>> Box[X] | Box[Int] | Box[String]]] | ||
summon[bap.MirroredElemTypes[Boolean] =:= ((Child[Boolean] | Child[Int] | Child[String]) *: EmptyTuple)] | ||
|
||
|
||
def testProducts = | ||
val foo = summon[Mirror.Of[Some[Int] | Some[String]]] | ||
summon[foo.MirroredElemTypes =:= ((Int | String) *: EmptyTuple)] | ||
|
||
val bar = summon[Mirror.Of[Child[Int] | Child[String]]] | ||
summon[bar.MirroredElemTypes =:= ((Int | String) *: EmptyTuple)] | ||
|
||
val qux = summon[Mirror.Of[Some[Int | String]]] | ||
summon[foo.MirroredElemTypes =:= ((Int | String) *: EmptyTuple)] | ||
|
||
val bip = summon[Mirror.Of[Child[Int | String]]] | ||
summon[bip.MirroredElemTypes =:= ((Int | String) *: EmptyTuple)] | ||
|
||
val bap = summon[MirrorK1.Of[[X] =>> Child[X] | Child[Int] | Child[String]]] | ||
summon[bap.MirroredElemTypes[Boolean] =:= ((Boolean | Int | String) *: EmptyTuple)] |