jacob
05/03/2019, 6:36 PMkitttn
05/04/2019, 12:44 PMstreetsofboston
05/04/2019, 1:08 PMIO
type better?Ryan Benasutti
05/05/2019, 3:48 AMsimon.vergauwen
05/05/2019, 1:50 PMarrow-effects-io-extensions
.jacob
05/05/2019, 3:12 PMSergio Crespo Toubes
05/09/2019, 7:41 AMunsafe {
runBlocking {
fx {
val posts = !mPostsApi.getPosts(authToken)
mView.showPosts(posts)
}.handleError {
Main.shift().map { mView.showGenericErrorAlert() }
}
}
}
jacob
05/11/2019, 3:37 PMGarth Gilmour
05/11/2019, 9:19 PMImran/Malic
05/12/2019, 4:55 PMjacob
05/13/2019, 1:00 PMstarke
05/15/2019, 5:31 PMOption
values
val option1 = Option.just("foo")
val option2 = Option.just(1)
val option3 = Option.just(Bar())
val result: Option<FooBar> = option1.flatMap { unwrappedValue1 ->
option2.flatMap { unwrappedValue2 ->
option3.map { unwrappedValue3 ->
FooBar(unwrappedValue1, unwrappedValue2, unwrappedValue3)
}
}
}
}
what is a better way to handle the use case where you want to return an Option
that is, for example, a composite of multiple other types that are wrapped by Option
I would like the resulting Option
to be None
if any of the other values are None
, otherwise return Some
that is a composite of the data from the other `Option`s…if that makes sense?Robert Menke
05/17/2019, 5:38 PMTry
it’s common to want to write to a log if an exception occurs. I’ve currently been using a pattern like the following, but I’m curious if there’s a more succinct or abstract way I can go about this:
Try { db.update(model) }
.toEither {
logger.error("My message", it.localizedMessage)
it
}
.fold(
{ /*handle failure*/ },
{ /*handle success*/ }
)
Thoughts on how to better handle this?raulraja
05/17/2019, 5:57 PMTry
is impure.simon.vergauwen
05/17/2019, 6:05 PMDerek Berner
05/17/2019, 7:58 PMciriti
05/18/2019, 1:13 PMraulraja
05/20/2019, 6:55 PMraulraja
05/20/2019, 7:45 PMJorge Castillo
05/22/2019, 1:58 PMBob Glamm
05/22/2019, 4:05 PMI’ve duct-taped OCaml to NodeJS
simon.vergauwen
05/23/2019, 3:12 PMTry.applicative().map(a(), b()) { a, b -> .. }
this should work 🙂pakoito
05/23/2019, 10:44 PMJoan Colmenero
05/24/2019, 1:26 PMraulraja
05/26/2019, 10:02 PMobjectMapper.convertValue
can fail with an exception then it should be suspended and you should be using IO
instead of Try
. Try is going away or going to be modified because it can’t suspend effects or run suspend functions. If we make Try support suspend then we have IO.
On a different token you can encode internally all your error handling efforts including validation without implying fail fast or error accumulation and then export a la carte in your public API the error strategies for each data type that you want to support.
This link supports with the same code both fail fast and error accumulation https://arrow-kt.io/docs/patterns/error_handling/#example--alternative-validation-strategies-using-applicativeerrorTom Hall
05/28/2019, 10:40 AMsimon.vergauwen
05/28/2019, 11:09 AMraulraja
05/28/2019, 8:18 PMpakoito
05/29/2019, 1:27 PMnoiano
05/29/2019, 2:27 PMnoiano
05/29/2019, 2:27 PMpakoito
05/29/2019, 4:30 PMraulraja
05/29/2019, 7:34 PMnoiano
05/30/2019, 1:55 PMraulraja
05/30/2019, 2:11 PMnoiano
05/30/2019, 2:57 PMpakoito
05/30/2019, 2:58 PMnoiano
05/30/2019, 2:59 PM