Roger 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() }
}
})
}
raulraja
02/12/2021, 7:19 PMraulraja
02/12/2021, 7:20 PMfix()
raulraja
02/12/2021, 7:21 PMRoger Gilliar
02/12/2021, 7:30 PMjulian
02/13/2021, 3:53 AMGleb Garipov
02/13/2021, 8:08 AMSatyam Agarwal
02/15/2021, 6:29 PMValidated
with applicative look like ? I use it a lot as I can collect errors in parallel like :
Validated
.applicative(NonEmptyList.semigroup<MyError>())
.mapN(...) { (a, b, c) -> ... }
.fix()
Satyam Agarwal
02/15/2021, 6:32 PMsuspend
, so doesn’t mix well with effectful methods and apis from arrow like Either.catch { … }
raulraja
02/16/2021, 10:32 AMval result =
ValidatedNel.mapN(
Semigroup.nonEmptyList(),
1.validNel(),
MyError.invalidNel(),
1.validNel()
) { a, b, c ->
...
}
mapN
here is also inlined so it will work across suspension as well.Carlos Fernandes
02/17/2021, 3:28 PM1.0
will be released without Higher Kinds, is there any examples to what the alternative will be?
Also any timeline projections for 0.12
and 1.0
?
Many thanks and keep up the good workraulraja
02/17/2021, 3:38 PMraulraja
02/17/2021, 3:39 PMibcoleman
02/19/2021, 1:42 PMfix()
is going away, and to use something like:
val result =
ValidatedNel.mapN(
Semigroup.nonEmptyList(),
1.validNel(),
MyError.invalidNel(),
1.validNel()
) { a, b, c ->
...
}
…but ValidatedNel.mapN
is an unresolved reference for me, using 0.11.0
. Is this something new in 0.12.0-SNAPSHOT? Implied user code I’m too slow to infer?
(Disclaimer: I’m enough of an Arrow newbie that @Satyam Agarwal’s example made sense, but @raulraja’s is utterly impenetrable to me.)
(I’m working my way through https://medium.com/google-developer-experts/advanced-fp-for-the-enterprise-bee-kleisli-1d0de0fa82d9 and https://www.manning.com/books/functional-programming-in-kotlin in the little downtime I’ve got, fwiw.)raulraja
02/19/2021, 2:19 PMmapN
appears on the companion of validated in 0.12.0 which will be released sometime in the following weeks. Prior to 0.12.0 mapN should be available as an extension import for the validated
extensions