Created
August 13, 2013 03:59
-
-
Save ethul/6217778 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
trait CPList { | |
type Apply[A] | |
type :+:[F[_]] <: CPList | |
type Append[T <: CPList] <: CPList | |
} | |
trait NilCP[F[_]] extends CPList { | |
type Apply[A] = F[A] | |
type :+:[G[_]] = ConsCP[G,NilCP[F]] | |
type Append[G <: CPList] = ConsCP[F, G] | |
} | |
trait ConsCP[H[_], T <: CPList] extends CPList { | |
type Apply[A] = Coproduct[H, T#Apply, A] | |
type :+:[F[_]] = ConsCP[F, ConsCP[H, T]] | |
type Append[G <: CPList] = ConsCP[H, T#Append[G]] | |
} | |
type W[A] = (NilCP[Test1Algebra] # :+: [Test2Algebra] # :+: [Test3Algebra])#Apply[A] | |
implicit def F0: Functor[W] = Coproduct.coproductFunctor[Test3Algebra, ({ type l[a] = Coproduct[Test2Algebra, Test1Algebra, a] })#l] | |
// Does not compile, needs the right inject instance | |
/* | |
val res = | |
for { | |
a <- test1[W]("aa" :: Nil) | |
b <- test2[W]("bb" :: Nil) | |
c <- test3[W]("cc" :: Nil) | |
} yield () | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment