Last active
August 29, 2015 14:02
-
-
Save wemrysi/0a04b1f2a4b36e89655c to your computer and use it in GitHub Desktop.
runFree
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
def runFree[S[+_], M[_]](f: S ~> M)(implicit M: Monad[M]): ({type λ[α] = Free[S, α]})#λ ~> M = | |
new (({type λ[α] = Free[S, α]})#λ ~> M) { | |
def apply[A](fr: Free[S, A]) = fr.foldMap[M, A](f) | |
} | |
def runFreeC[S[+_], M[_]](f: S ~> M)(implicit M: Monad[M]): ({type λ[α] = FreeC[S, α]})#λ ~> M = | |
new (({type λ[α] = FreeC[S, α]})#λ ~> M) { | |
def apply[A](fr: FreeC[S, A]) = fr.runM[M, A](coyo => M.map(f(coyo.fi))(coyo.k)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment