Second stupid question: my naive implementation of...
# arrow
b
Second stupid question: my naive implementation of iterating over ResultSet results in a StackOverflowError:
Copy code
fun <T> mapResult(rs: ResultSet, mapper: (ResultSet) -> IO<T>): IO<List<T>> =
            IO.fx().fx {
                val (hasNext) = rs.hasNext()  // ResultSet.hasNext :: (Unit) -> IO<Boolean>)
                if (hasNext) {
                    val (t) = mapper(rs)
                    val (remainder) = mapResult(rs, mapper)
                    t.prependTo(remainder)
                } else {
                    listOf()
                }
            }.fix()
How do I avoid this in general? I've done this a couple of times now.