Never used Arrow before but trying to improve my e...
# arrow
g
Never used Arrow before but trying to improve my error handling and excited about Railway Oriented Programming. To keep it practical, how do you model your http request response with Arrow? I've seen something "Use
Try
in data layer, then map to
Either
for domain". Am I on the right track? Any good hands-on articles, like "Retrofit + Arrow, error handling"? Thank you.
g
Use
Try
in data layer
I don’t think that it’s the case anymore. Try is deprecated, and recommended to use IO, see the article above
👍🏼 1
g
UPD: Retrofit + coroutines + arrow (?)
g
There is official integration with Arrow Higher Kinded Types including Try and IO and own HK CallK https://arrow-kt.io/docs/integrations/retrofit/
There is also kotlinx.coroutines adapter;
p
perfect reply, thanks @gildor!!
🙏 1
s
Is it recomended to use IO instead of Either.catch { }?
(I have not looked into IO yet so I'm not aware of the difference)
p
Use IO where you reach the limit of suspend functions returning Either, i.e. when you need to change threads or run things in parallel
If it's just boring sequential code then suspend fun bla(): Either<Throwable, User> = Either.catch { ... } works great