Created
October 5, 2014 11:31
-
-
Save EECOLOR/3446d8a6defa22b25ea6 to your computer and use it in GitHub Desktop.
Clean construction of coproducts
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 Co[F[_], G[_]] { | |
case class Product[A](value: Either[F[A], G[A]]) | |
} | |
trait ProgramType[F[_]] | |
object ProgramType { | |
def apply[T](implicit to: ToParameterized[T]): ProgramType[to.Out] = ??? | |
} | |
trait ToParameterized[T] { | |
type Out[_] | |
} | |
object ToParameterized { | |
implicit def withEmpty[F[_]]:ToParameterized[F +: Nil] { | |
type Out[A] = F[A] | |
} = null | |
implicit def typeSet[F[_], G[_], X]( | |
implicit to: ToParameterized[G +: X]):ToParameterized[F +: G +: X] { | |
type Out[A] = Co[F, to.Out]#Product[A] | |
} = null | |
} | |
trait +:[F[_], Types] | |
trait Nil | |
implicit val programType = ProgramType[Store +: Json +: Utilities +: Nil] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment