Last active
November 6, 2016 22:23
-
-
Save chenharryhua/c0a92f091fa260542cd17b4b4aa52947 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
package yoneda | |
import language.higherKinds | |
import scalaz._ | |
import Scalaz._ | |
/** | |
* A => ? to F is nature transformation, encoded as ~>[(A => ?), F] | |
* f and g are the witness of the fact that: | |
* the nature transformation of A => ? to F is isomorphic to F[A] | |
*/ | |
object Lemma { | |
def f[F[_], A, R](k: ~>[(A => ?), F]): F[A] = k(identity) | |
def g[F[_]: Functor, A](fa: F[A]): ~>[(A => ?), F] = new ~>[(A => ?), F] { | |
def apply[R](aa: A => R): F[R] = fa.map(aa) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment