Created
October 9, 2014 21:45
-
-
Save jedws/05fca3c24f1a4cc6c8fc to your computer and use it in GitHub Desktop.
lift a NaturalTransform into a type constructor that has a functor
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
import scalaz._ | |
import scalaz.syntax.functor._ | |
object LiftNaturalTransform { | |
def transform[F[_], G[_], M[_]: Functor, A](implicit nt: F ~> G): M[F[A]] => M[G[A]] = | |
_ map nt.apply | |
implicit class NaturalTransformSyntax[F[_], G[_]](f2g: F ~> G) { | |
def lift[M[_]: Functor] = | |
new NaturalTransformation[({ type λ[α] = M[F[α]] })#λ, ({ type λ[α] = M[G[α]] })#λ] { | |
def apply[A](mf: M[F[A]]): M[G[A]] = | |
Functor[M].apply(mf)(f2g) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment