Created
December 1, 2016 21:40
-
-
Save edmundnoble/44e17ce1665076a7e82f6115efc8b2b1 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
@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