CLOVIS
10/09/2023, 2:14 PMnullableLossy
to convert any function declared with Raise
, transforming any failed values in null
→ https://github.com/arrow-kt/arrow/issues/3138Javier
10/09/2023, 3:07 PMsimon.vergauwen
10/09/2023, 3:07 PMrecover({ blabla() }) { null }
, right?getOrNull { }
but that looks weird 😄effect { }.getOrNull()
also worksCLOVIS
10/09/2023, 3:08 PMSo an alias forYes, that's an easier way to write it than, right?recover({ blabla() }) { null }
either { }.getOrNull()
Javier
10/09/2023, 3:09 PMgetOrNull { }
, but it is a global function which looks generic but only works with Raise
, I don't think it is a good namesimon.vergauwen
10/09/2023, 3:09 PMJavier
10/09/2023, 3:10 PMrunCatching
, but I cannot get a good name... yeah, hard nameCLOVIS
10/09/2023, 3:10 PMThat name cannot be hard to find?Honestly, I have always expected
nullable
to behave like this. I believe many other people may as well, which is the reason I want to name it nullableXXX
, so you can discover it through auto-completeJavier
10/09/2023, 3:10 PMfromEffectOrNull { }
• fromRaiseOrNull { }
raise
in the nameCLOVIS
10/09/2023, 3:12 PMfrom
isn't really a prefix I see often?
• effectOrNull {}
: but it's called Raise
now, right? Why introduce something using the old name?
• raiseOrNull {}
: that really looks like something that raises, not something that capture raisesI would look to something that start or at least includesI don't know, all existing builders are named after what they produce—it's notin the nameraise
eitherFromRaise
, nullableFromRaise
, etcJavier
10/09/2023, 3:12 PMfrom
too, just throwing ideassimon.vergauwen
10/09/2023, 3:13 PMrecoverNull { }
?recover({ }) { null }
pattern 🤔recoverOrNull
seems incorrect 😄Javier
10/09/2023, 3:13 PMrecoverOrNull
simon.vergauwen
10/09/2023, 3:14 PMrecoverWithNull { }
CLOVIS
10/09/2023, 3:14 PMrecoverNull
means "do some recovery when the block returns `null`"recoverWithNull
sounds finenullableLossy
is, though: it's a variant of nullable
, but swallows the errorJavier
10/09/2023, 3:17 PMrecover { }.orNull()
correct?simon.vergauwen
10/09/2023, 3:17 PMLossy
tbh 😅, and creating more sublanguagerecover { }.getOrNull()
is what you could do with effect { }.getOrNull()
but it's the same in length as what @CLOVIS is trying to solve either { }.getOrNull()
CLOVIS
10/09/2023, 3:19 PMfun fooOrNull() = either { // why it is building an either?
// a lot of code
}.getOrNull() // nobody expects something to happen after the closing brackets
Javier
10/09/2023, 3:19 PMnullable
as a prefix, so for a beginner, it will be impossible to find it.simon.vergauwen
10/09/2023, 3:19 PMnullable { }
in Arrow 🙃Javier
10/09/2023, 3:20 PMCLOVIS
10/09/2023, 3:20 PMJavier
10/09/2023, 3:20 PMgetOrNull
APIsCLOVIS
10/09/2023, 3:21 PMfun foo() = recover({
// a lot of code
}) { null }
but the brackets have to be inside the parens, which I'm not a fan of for large functions, it breaks the mental model of "`either` is a decorator of the rest of the function"Javier
10/09/2023, 3:24 PM({
, I use named params in those use cases.simon.vergauwen
10/09/2023, 3:25 PM({
😂 it's a necessary evil sadly somtimesCLOVIS
10/09/2023, 3:26 PMfun foo() = recover(
block = {
// a lot of code
},
recover = { null },
)
is readable, but it's much more verbose, and now the code is 2-levels deep inside of 1simon.vergauwen
10/09/2023, 3:27 PMCLOVIS
10/09/2023, 3:28 PMsimon.vergauwen
10/09/2023, 3:28 PMeither { }.getOrNull()
tbh, it's probably going to be most readableCLOVIS
10/09/2023, 3:30 PMeither {}
call to have anything at its endJavier
10/09/2023, 3:49 PMnullable {}
? But it would need to have the same package as the original one in order to have priorityCLOVIS
10/09/2023, 3:52 PMWhat aboutI feel like it would be really confusing to have two functions with the same name, one of which swallowing errors silently?nullable {}
simon.vergauwen
10/09/2023, 3:52 PMStylianos Gakis
10/09/2023, 10:00 PMeither { }.getOrNull()
or just effect {}.getOrNull()
here, and if a new function was introduced in our local codebase I’d probably advocate against it. Easier to use the standard tools that everyone understands and use them together as they are meant to be used, as opposed to introducing yet another function which simply wraps 2 function calls which will be looking foreign to most arrow users.Davio
10/10/2023, 7:04 AMrunCatching
has getOrNull
Optional
has getOrNull
Casting methods have 'orNull' variants such as toIntOrNull
as a way to turn the exception into a null-valueAlejandro Serrano.Mena
10/11/2023, 7:16 AMnullable
but introduce ignoreErrors
that does exactly that https://apidocs.arrow-kt.io/arrow-core/arrow.core.raise/-nullable-raise/ignore-errors.htmlCLOVIS
10/11/2023, 7:23 AMfun fooOrNull() = nullable {
ignoreErrors { foo() }
}
Alejandro Serrano.Mena
10/11/2023, 7:23 AMCLOVIS
10/11/2023, 7:24 AMAlejandro Serrano.Mena
10/11/2023, 7:26 AM