```override fun getElements(): Either<Throwable...
# arrow
s
Copy code
override fun getElements(): Either<Throwable, List<Element>> {
	return elementsApi.getElements(authToken)
		.async(IO.async())
		.fix()
		.unsafeRunSync()
		.unwrapBody(Either.applicativeError())
		.fix()
}
This is working for me, but is the good way for using arrow with retrofit?
getElements
return CallK object.
r
Ideally you never abandon
IO
IO is more powerful than Either and if your functions are effectful and want to keep them pure you should return IO until at the edge you call
unsafeRunAsync
or equivalent
s
but how can i unwrap the response without abandon
IO
?
r
Copy code
elementsApi.getElements(authToken)
        .async(IO.async())
        .fix()
        .attempt()
or if you don't want the nested either don't call
attempt
that should return an IO value you can still compose
s
fun getElements(): IO<List<Element>>
has the same semantics as
Either<Throwable, ..>
and allows for similar error handling with
errorHandleWith
,
attempt
or similar combinators.
s
Thanks for your help
👍 2