Skip to content

Instantly share code, notes, and snippets.

@debasishg
Created April 17, 2011 15:36
Show Gist options
  • Save debasishg/924143 to your computer and use it in GitHub Desktop.
Save debasishg/924143 to your computer and use it in GitHub Desktop.
@runanorama's code snippet for using iteratee based JDBC results processing
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