Bob Glamm
07/24/2019, 5:23 PMfun <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.