Skip to content

Instantly share code, notes, and snippets.

@edmundnoble
Created December 1, 2016 21:40
Show Gist options
  • Save edmundnoble/44e17ce1665076a7e82f6115efc8b2b1 to your computer and use it in GitHub Desktop.
Save edmundnoble/44e17ce1665076a7e82f6115efc8b2b1 to your computer and use it in GitHub Desktop.
@inline final def cataM[F[_] : Traverse, M[_] : Monad, A]
(tf: Fix[F])(destroy: F[A] => M[A]): M[A] = {
val projected: F[Fix[F]] = tf.unFix
val looped: M[F[A]] = projected.traverse[M, A](cataM(_)(destroy))
val destroyed: M[A] = looped.flatMap(destroy)
destroyed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment