Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
object StreamT extends StreamTInstances {
def unfoldM[M[_],A,B](start: B)(f: B => M[Option[(A,B)]])(implicit M: Functor[M]): StreamT[M,A] =
StreamT[M,A]( {
case Some((a, b)) => Yield(a, unfoldM(b)(f))
case None => Done
def unfold[A,B](b: B)(f: B => Option[(A,B)]): StreamT[Id,A] = unfoldM[Id,A,B](b)(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment