Created
March 12, 2014 07:53
-
-
Save japgolly/9502607 to your computer and use it in GitHub Desktop.
Coyoneda natural transformations
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 ForScalaz { | |
type CoyonedaF[F[_]] = ({type A[α] = Coyoneda[F, α]}) | |
def FG_to_CFG[F[_], G[_] : Functor, A](t: F ~> G): (CoyonedaF[F]#A ~> G) = { | |
type CF[A] = Coyoneda[F, A] | |
type CG[A] = Coyoneda[G, A] | |
val m: (CF ~> CG) = FG_to_CFCG(t) | |
val n: (CG ~> G) = CF_to_F | |
val o: (CF ~> G) = n compose m | |
o | |
} | |
def FG_to_CFCG[F[_], G[_]](f: F ~> G): (CoyonedaF[F]#A ~> CoyonedaF[G]#A) = | |
new (CoyonedaF[F]#A ~> CoyonedaF[G]#A) { | |
def apply[X](c: CoyonedaF[F]#A[X]): CoyonedaF[G]#A[X] = c.trans(f) | |
} | |
def CF_to_F[F[_] : Functor]: (CoyonedaF[F]#A ~> F) = | |
new (CoyonedaF[F]#A ~> F) { | |
def apply[X](c: CoyonedaF[F]#A[X]): F[X] = c.run | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment