dave08
07/17/2023, 1:39 PMval foo: Either<Error, List<Bar>>?
nullable {
val baz: List<Bar> = foo.bind().bind() // this doesn't seem to be valid... how do I do this?
val baz2: List<Bar> = ensureNotNull(foo).bind() // this also doesn't seem to be valid...
}
Alejandro Serrano Mena
07/17/2023, 1:46 PMnullable
you can only raise
values of type null
(so you don’t “forget” information, although this design could be revisited)Alejandro Serrano Mena
07/17/2023, 1:46 PMfoo.mapLeft { null }.bind()
Alejandro Serrano Mena
07/17/2023, 1:47 PM?
at the endAlejandro Serrano Mena
07/17/2023, 1:47 PMfoo.bind().mapLeft { null }.bind()
dave08
07/17/2023, 1:49 PMbind()
with a different name for this, so that people will make the conscious choice to ignore the extra information...dave08
07/17/2023, 1:50 PMnullable { }
was to go with the happy path... and let everything else be null.dave08
07/17/2023, 1:53 PMbind { null }
for `Either`s? Or ``bindOrMap { null }` ... would be better than using two different binds meaning two different things and that map in the middle...Alejandro Serrano Mena
07/17/2023, 2:16 PMAlejandro Serrano Mena
07/17/2023, 2:19 PMdave08
07/17/2023, 2:21 PMYoussef Shoaib [MOD]
07/17/2023, 3:09 PMnullable {
withError({ _: Any? -> null}) {
foo.bind().bind()
}
}
Maybe this pattern should have a raise builder? Maybe something like nullableAny {}
that forgets all the error information.Youssef Shoaib [MOD]
07/17/2023, 3:12 PMraiseAny
because it won't work well with context receivers. I think nullable should simply have Raise<Any?>
Inside of it, or we should introduce a new builder that does that, but having a new method won't work in a contexts world.dave08
07/17/2023, 3:15 PMYoussef Shoaib [MOD]
07/17/2023, 3:17 PMignoreErrors { }
block that only works inside a Raise<Null>
and gives you a receiver of Raise<Any?>
, Although I can see how that's less user friendlyAlejandro Serrano Mena
07/17/2023, 3:46 PMAlejandro Serrano Mena
07/17/2023, 5:45 PMAlejandro Serrano Mena
07/17/2023, 8:17 PMwithError
, because ignoreErrors
is simply withError
with a bit better inferencedave08
07/18/2023, 8:55 AMAlejandro Serrano Mena
07/19/2023, 7:04 AM