Skip to content

Instantly share code, notes, and snippets.

@oluies
Created October 8, 2011 16:27
Show Gist options
  • Save oluies/1272501 to your computer and use it in GitHub Desktop.
Save oluies/1272501 to your computer and use it in GitHub Desktop.
enumResultSet
def enumResultSet[E,A](rs: ResultSet, iter: IterV[E, A], get: ResultSet => IO[E]): IO[IterV[E, A]] = {
def loop(i: IterV[E, A]): IO[IterV[E, A]] =
i.fold(done = (_, _) => i.pure[IO],
cont = k => next(rs) >>= (hasMore =>
if (!hasMore) i.pure[IO]
else get(rs) >>= (t => loop(k(El(t))))))
loop(iter)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment