Created
September 18, 2019 15:33
-
-
Save makenowjust/e36dd380791f3658d3990ed66898ed3b to your computer and use it in GitHub Desktop.
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
object scope { | |
// int | |
class I | |
// list | |
sealed trait L[A] | |
class N[A] extends L[A] | |
class C[A] extends L[A] | |
// tree | |
class T[A] | |
// hlist | |
trait HList | |
class HNil extends HList | |
class :*:[H, T <: HList] extends HList | |
// coproduct | |
trait Coproduct | |
class CNil extends Coproduct | |
class :+:[H, T <: Coproduct] extends Coproduct | |
// typefunction1 | |
trait TF1 { type Apply[A] } | |
trait HList1 extends TF1 { type Apply[A] <: HList } | |
trait HNil1 extends HList1 { type Apply[_] = HNil } | |
trait :**:[H <: TF1, T <: HList1] extends HList1 { type Apply[A] = H#Apply[A] :*: T#Apply[A]} | |
trait Coproduct1 extends TF1 { type Apply[A] <: Coproduct } | |
trait CNil1 extends Coproduct1 { type Apply[_] = CNil } | |
trait :++:[H <: TF1, T <: Coproduct1] extends Coproduct1 { type Apply[A] = H#Apply[A] :+: T#Apply[A] } | |
trait P1 extends TF1 { type Apply[A] = A } | |
trait K1[C] extends TF1 { type Apply[_] = C } | |
trait R1[G[_]] extends TF1 { type Apply[A] = G[A] } | |
// functor | |
trait F[G[_]] | |
object F { | |
implicit def g[G[_], R <: TF1](implicit GR: G1[G, R], R: GF[R]): F[G]= ??? | |
} | |
// generic1 | |
trait G1[G[_], R <: TF1] | |
object G1 { | |
implicit val l: G1[L, R1[N] :++: R1[C] :++: CNil1] = ??? | |
implicit val n: G1[N, HNil1] = ??? | |
implicit val c: G1[C, P1 :**: R1[L] :**: HNil1] = ??? | |
type LT[A] = L[T[A]] | |
type NT[A] = N[T[A]] | |
type CT[A] = C[T[A]] | |
implicit val t: G1[T, P1 :**: R1[LT] :**: HNil1] = ??? | |
implicit val lt: G1[LT, R1[NT] :++: R1[CT] :++: CNil1] = ??? | |
implicit val nt: G1[NT, HNil1] = ??? | |
implicit val ct: G1[CT, R1[T] :**: R1[LT] :**: HNil1] = ??? | |
} | |
// gfunctor | |
trait GF[R <: TF1] | |
object GF { | |
implicit val hnil: GF[HNil1] = ??? | |
implicit def hcons[H <: TF1: GF, T <: HList1: GF]: GF[H :**: T] = ??? | |
implicit val cnil: GF[CNil1] = ??? | |
implicit def ccons[H <: TF1: GF, T <: Coproduct1: GF]: GF[H :++: T] = ??? | |
implicit val p: GF[P1] = ??? | |
implicit def k[C]: GF[K1[C]] = ??? | |
implicit def r[G[_]](implicit G: => F[G]): GF[R1[G]] = ??? | |
} | |
} | |
import scope._ | |
implicitly[F[T]] | |
F.g( // o-----------------------------------------+ | |
G1.t, // | | |
GF.hcons( // | | |
GF.p, // | | |
GF.hcons( // | | |
GF.r[G1.LT]( // | | |
F.g( //o----------------------------------+--+ | |
G1.lt, // | | | |
GF.ccons( // | | | |
GF.r[G1.NT](F.g(G1.nt, GF.hnil)), // | | | |
GF.ccons( // | | | |
GF.r[G1.CT]( // | | | |
F.g( // | | | |
G1.ct, // | | | |
GF.hcons( // | | | |
GF.r[T](???), // <------------+ | | |
GF.hcons( // | | |
GF.r[G1.LT](???), // <---------+ | |
GF.hnil, | |
), | |
), | |
), | |
), | |
GF.cnil, | |
), | |
), | |
), | |
), | |
GF.hnil, | |
), | |
), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment