Trying to bring more Arrow in that project. Why do...
# arrow
b
Trying to bring more Arrow in that project. Why does work return IO<Any> and not IO<Obj> ?
Copy code
import <http://arrow.effects.IO|arrow.effects.IO>
import arrow.effects.extensions.io.monad.binding

data class Obj(val a: String)

sealed class KnownError : RuntimeException()
object DecodingError : KnownError()


fun apiCall(s: String) = IO {
    "Some string"
}

fun convert(s: String): Obj? {
   return Obj("Some other output")
}

fun work(s: String): IO<Obj> =
    IO.run {
        binding {
            val output = apiCall(s)

            val obj = convert(output.bind())

            if (obj != null)
                obj
            else
                raiseError<Obj>(DecodingError)

        }
    }