Skip to content

Instantly share code, notes, and snippets.

@chenharryhua
Last active November 6, 2016 22:23
Show Gist options
  • Save chenharryhua/c0a92f091fa260542cd17b4b4aa52947 to your computer and use it in GitHub Desktop.
Save chenharryhua/c0a92f091fa260542cd17b4b4aa52947 to your computer and use it in GitHub Desktop.
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