Attila Domokos
04/10/2020, 6:55 PMEitherT, I used it a couple of days ago here when I tried upgrading to v0.10.5.
typealias EitherIO<A> = EitherT<String, ForIO, A>
...
private fun readConfiguration(): EitherIO<T.Configuration> =
EitherT(IO.fx {
val config = T.Configuration(
System.getenv("CLIENT_ID"),
System.getenv("CLIENT_SECRET"))
Right(config)
}.handleError { Left("No CLIENT_ID or CLIENT_SECRET was found") })
I upgraded to 0.11.0-SNAPSHOT and tried converting this code to this version of Arrow. This worked:
private fun readConfiguration(): IO<String, T.Configuration> =
IO.fx<String, T.Configuration> {
val config = T.Configuration(
System.getenv("CLIENT_ID"),
System.getenv("CLIENT_SECRET"))
config
}// .handleError("No CLIENT_ID or CLIENT_SECRET was found")
However, I really liked handleError() , I'd like to return the string I have in comment out part if something goes awry in this call chain.
Is there a documentation on how to handle this?
Most of the examples I've seen in Arrow's source code is IO<Nothing, A>, which is not really helpful. I'd like to use my own type (or String) to represent errors.