Skip to content

Instantly share code, notes, and snippets.

@qingwei91
Created March 14, 2019 20:40
Show Gist options
  • Select an option

  • Save qingwei91/b1b5bebdf28e5132343f00af12d6e054 to your computer and use it in GitHub Desktop.

Select an option

Save qingwei91/b1b5bebdf28e5132343f00af12d6e054 to your computer and use it in GitHub Desktop.
type HAlgebra[F[_[_], _], G[_]] = F[G, ?] ~> G
def hCata[F[_[_], _], G[_], I](alg: HAlgebra[F, G],hfix: HFix[F, I])(implicit F: HFunctor[F]): G[I] = {
val inner = hfix.unfix
val nt = F.hmap(
new (HFix[F, ?] ~> G) {
def apply[A](fa: HFix[F, A]): G[A] = hCata(alg, fa)
}
)(inner)
alg(nt)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment