CLOVIS
02/10/2021, 8:20 AMvalue class
and it sounds like something Arrow would be really interested in (immutable classes that have mutators that return copies). Do you have plans to use these features? They seem to clash with Lens, but maybe they could work well together?cavega
02/12/2021, 4:03 AMEither
such that if Left
meets some specific condition (i.e. filter out some error code that should not throw an error) the downstream Either via the fold operation gets routed to ifRight
?
I did something like this (where Either<List<MyErrors>, <Data>>):
return someService()
.map { it.toEither().mapLeft {
it.filter { it.code != "some-failure-code" }
} }
But all that does in return an empty list of MyErrors to the downstream fold’s isLeft.Ifvwm
02/12/2021, 1:36 PMRoger Gilliar
02/12/2021, 6:35 PMfun validate(
p: Player,
i: Idea.OpenIdea,
members: Eval<NonEmptyList<Member>>
): Either<NonEmptyList<ValidationError>, UnvalidatedPlayer> {
return (Rules failFast {
UnvalidatedPlayer(p, i)
.let {
it.accountNotLocked(TeamDbRepository)
.flatMap { it.notMember().fix() }
.flatMap { it.hasEnoughSkills().fix() }
.flatMap { it.notTooManyUnfinishedIdeas().fix() }
.flatMap { it.budgetLimitNotReached().fix() }
.flatMap { it.suitableDepartment(TeamDbRepository).fix() }
.flatMap { it.skillsInLimit(members, TeamDbRepository).fix() }
.flatMap { it.teamNotComplete(members).fix() }
.flatMap { it.cantAddAgain(PlayerRepository).fix() }
}
})
}
julian
02/15/2021, 7:56 PMRoger Gilliar
02/16/2021, 7:31 AMBrad M
02/20/2021, 11:24 PMgenovich
02/21/2021, 8:35 PMCLOVIS
02/22/2021, 4:23 PMcancelBoundary()
(in the last example of https://arrow-kt.io/docs/integrations/kotlinxcoroutines/) ?Jörg Winter
02/24/2021, 5:52 PMarrow-fx
and not necessarily on arrow-fx-coroutines
?
(0.12-SNAPSHOT)dephinera
02/27/2021, 11:21 AMMarius Kotsbak
03/01/2021, 9:15 AM}.mapLeft { throw it }
(on Either<Throwable, A>). Is this or should be part of the lib? I can't find out what rethrow() does, if it it is the same. Or something like getOrThrow.ibcoleman
03/01/2021, 7:38 PMEither<A, Either<A, B>>
into an Either<A, B>
(Sorry for the basic question)simon.vergauwen
03/03/2021, 3:19 PM0.12.0
and 0.13.0
are coming really soon 😅 We're in the last 5% but you know how those go we don't have to explain to each other 😂Orhan Tozan
03/04/2021, 7:42 PMJimmy Alvarez
03/04/2021, 7:49 PMsuspend fun killSession(): Either<LowUnprotectedError, Unit>
use void to represent the the effect full operation but feels wear, i think should be a better way to represent this kind of operationsMarius Kotsbak
03/05/2021, 9:53 AMGopal S Akshintala
03/05/2021, 10:26 AMtypealias _Validator_<_ValidatableT_, _FailureT_> = _suspend_ (_ValidatableT_) -> _Either_<_FailureT_, Any?>
Within Kotlin, I use it like this as a data type to assign to a lamda val validateParent3X: _Validator_<_Egg_, _ValidationFailure_> = {...}
But I cannot use typealias from Java. What is the idiomatic way to use this Function type as data type on Java?
I see two unknows I have for java interoperability. 1. How can I idimotically refer a Function type 2. Function type being suspend
carbaj0
03/07/2021, 1:38 PM123
03/08/2021, 9:24 PMdata classes
, high order funcs and etc.
Any comprehensive open-source project (preferable Kotlin+Spring) which heavily uses Arrow (core, optics) you could recommend to dig in?CLOVIS
03/08/2021, 10:01 PMrequire()
, check()
and error()
to shortcut execution. Either is much more “precise” and “safe”, however I don't know how to write something as concise and readable:
fun foo(param: Int) {
require(param > 1) { "Some message here" }
doSomething() ?: error("that's not possible")
}
I guess the either
block should help with this, but I don't really see how to use it for these cases.andries.fc
03/09/2021, 7:30 AMBenoît
03/09/2021, 4:45 PMDennis Tel
03/09/2021, 6:30 PMibcoleman
03/09/2021, 11:40 PMsuspend fun String.parseAgeString(): ValidatedNel<ValidationError, Int> =
this.parseToInt().mapLeft{ Nel.just(ValidationError.InvalidAge) }
But I’m having a hard time trying to figure out how to chain additional validation rules---say we have a Valid value but it has to be greater than 18 or it returns another distinct ValidationError.pakoito
03/10/2021, 4:47 PMfun (Traverse<F>, Applicative<G>, Kind<F, Kind<G, A>>).sequence(): Kind<G, Kind<F, A>> =
traverse(::it)
André Thiele
03/11/2021, 11:46 AMJörg Winter
03/11/2021, 5:01 PMValidated.mapN(Semigroup.nonEmptyList(), ...)
gone in 0.12 snapshot ?Oliver Eisenbarth
03/11/2021, 9:24 PMCody Mikol
03/11/2021, 11:28 PMeither<L,R> { }
I understand that you can bind getting some value to the context of that either, so I can do something like
val foo = !service.getThingViaEither()
What is the correct way to handle this in conjunction with validation where the return type doesn’t necessarily matter?
Currently I’m doing something like
!Either.conditionally(foo.isValid(), { Error("bar") }, { true }))
I could also do something like
val isValid = !checkFooValid(foo)
but that also seems unnecessary as the isValid val will never be usedCody Mikol
03/11/2021, 11:28 PMeither<L,R> { }
I understand that you can bind getting some value to the context of that either, so I can do something like
val foo = !service.getThingViaEither()
What is the correct way to handle this in conjunction with validation where the return type doesn’t necessarily matter?
Currently I’m doing something like
!Either.conditionally(foo.isValid(), { Error("bar") }, { true }))
I could also do something like
val isValid = !checkFooValid(foo)
but that also seems unnecessary as the isValid val will never be usedCLOVIS
03/12/2021, 7:02 AMval isValid = !checkFooValid(foo)
you could just write
!checkFooValid(foo)
No need to declare a variable you're not using.raulraja
03/12/2021, 9:27 AMcheckFooValid(foo).bind()
invoke
, not
, componentX
are gone.Cody Mikol
03/12/2021, 3:17 PM