Bart Kleijngeld
03/22/2022, 2:56 PMSet<X>
collections, and I want to see if they contain equal items. The challenge is that this equality must be tested by some external isomorphic
function (which takes two arguments of type X
) instead of the standard equality operator.
Can someone point towards helpful ideas or tools in Kotlin/Arrow?rcd27
03/22/2022, 6:31 PMMap<Int,List<ONE>>
Map<Int,List<TWO>>
...
Map<Int,List<N>>
Is there any "instrument" I can zip it to Map<Int, Tuple<ONE,TWO,...,N>>
where ints represent unique numbers which present in each Map?pepe
03/23/2022, 3:37 PMOption.fromNullable(nullableValue).mapNotNull(::f1).flatMap(::f2)
where f1 is suspend (String) -> String?
and f2 is suspend (String) -> Option(Whatever)
, is this supported?Francesco Bonnì
03/29/2022, 7:08 AMTiberiu Tofan
03/30/2022, 11:11 AMeither {}
vs either.eager {}
. I admit that I didn’t fully understand the implementation for the eager variants. Is my assumption correct? Would this be an important argument for using the suspended variant?Satyam Agarwal
03/30/2022, 12:00 PMReturning type parameter has been inferred to Nothing implicitly. Please specify type arguments explicitly to hide this warning. Nothing can produce an exception at runtime.
What are the implications of this, apart from readability that MyError.left().bind()
is not clear in what the RHS can be.
iirc, its not trivial to remove these errors, they can only be suppressed. Is there any work being done in fixing this ?
Also, MyError.left().bind()
is this recommended approach ? I often use filterOrOther to avoid warnings.rcd27
04/03/2022, 11:32 AMgabib
04/04/2022, 2:47 PMinline fun <E, B> Either<E, B?>.leftIfNotNull(f: () -> E): Either<E, Nothing?> = flatMap { it.rightIfNull { f() } }
Is there something that might have helped in Arrow and I've missed it?Satyam Agarwal
04/06/2022, 11:58 AMEmil Kantis
04/06/2022, 3:19 PMList<ValidatedNel<E, A>>
-> ValidatedNel<E, List<A>>
, is there any such method? 🙂jeff
04/06/2022, 4:38 PMPavel
04/06/2022, 5:49 PMAlan B
04/13/2022, 5:34 PMiguissouma
04/15/2022, 9:04 AM/**
* Given a path as string dot-separated component, extracts the item found at that path location.
* Eg.:
* Given m = mapOf("p1" to mapOf("p2" to "value_1_2"))
* Then m.readPath("p1.p2") -> Option["value_1_2"]
*/
inline fun <reified T> Map<String, Any>.readPath(pathComponents: String): Option<T> {
val extract = { v: Any, p: String -> (v as? Map<*, *>)?.get(p).toOption() }
return pathComponents.split(".").foldM(Option.monad(), this, extract).fix().flatMap { (it as? T).toOption() }
}
Ron S
04/24/2022, 2:58 PMIvan Dugalic
04/24/2022, 4:20 PMeither
to Effect
. I like it BTW, it is a nice abstraction IMHO. But I have some issues. It is a multiplatform project and issue might not be related to Arrow, but it emerged once I switched to Effect
. It looks related to native
target(s) only. More in the thread …phldavies
04/24/2022, 7:19 PMMervyn McCreight
04/26/2022, 9:13 AM1.1.2
for now, coming from a pure jvm-project, or should I wait for the official announcement and release blogpost before updating? 🙂Dirk
04/26/2022, 2:35 PMchristophsturm
04/27/2022, 8:11 AMthanh
04/27/2022, 9:04 AMfutureOr
function:
suspend fun fu(i: Int): Boolean = TODO()
suspend fun futureOr(fs: List<Int>): Boolean =
fs.parTraverse { fu(it) }.reduce { acc, b -> acc || b }
Now it needs to wait for all of suspend function completed. But we know that if there is one of the fu(it)
return false
we can return false
and cancel the rest. Not sure how to do it nicely here.christophsturm
04/27/2022, 1:15 PMYannick Lazzari
04/27/2022, 4:13 PMfun <A,B> Either<A, B>.throwException(f: (A) -> Unit): Unit = when (this) {
is Either.Left -> f(this.value)
else -> Unit
}
which I then use like this:
val someResult: Either<SomeErrorADT, String> = ...
someResult.throwException {
when (it) {
SomeErrorADT.Error1 -> throw SomeException1("...")
SomeErrorADT.Error2 -> throw SomeOtherException("...")
}
}
Is there an existing function or extension function that exists in Arrow that kind of does the same thing that I’m not seeing?Jonathan De Leon
04/27/2022, 7:18 PMSchedule
to repeat an operation. Is there a way to get the delay after adding jitter to the schedule. Better yet, is there a way to get how much time has elapsed since the start of the schedule.
Schedule.exponential<SomeResult>(someConfigDelay)
.jittered()
.whileOutput { it < someConfigMaxDelay }
.logOutput { log.debug("Current delay: $it - ${it.inWholeNanoseconds} ns") }
phldavies
04/28/2022, 11:40 AMinternal infix fun <A, B> Resource<A>.flatTap(resource: (A) -> Resource<B>): Resource<A> =
flatMap { a -> resource(a).map { a } }
which allows for constructs such as
fun CoroutineScope.myProcessor(database: Database) = resource {
MyProcessor(coroutineContext, database)
} release {
it.close()
} flatTap {
resource { it.backgroundWorker() } release Job::cancel
}
Effectively allowing for similar usages as tap {}
but with a teardown/release.Satyam Agarwal
04/28/2022, 2:38 PMphldavies
04/29/2022, 1:19 PMResource.parZip
when `parZip`ing a `parZip`’d resource 🙂
suspend fun main() = int(1)
.parZip(int(2), Int::plus)
.parZip(int(3), Int::times)
.use { println("using $it") }
private fun int(n: Int) = resource {
n.also { println("acquiring $it") }
} release {
println("releasing $it")
}
outputs
acquiring 2
acquiring 1
acquiring 3
using 9
releasing 3
and never releases 1 and 2Yannick Lazzari
04/29/2022, 4:01 PMphldavies
04/29/2022, 4:59 PMresource { }
DSL releases resources in the wrong order - see 🧵julian
04/29/2022, 6:50 PMtap
operators for quite a while, until I realized that maybe it wasn't meant to denote "knock" (like knock/tap on the door), but rather "faucet".
This may be the result of living in the US where no one says "tap"; they say "faucet". And while "tap" is also a verb, "faucet" is always a noun. To "tap" is to "runTheFaucet" in the US.
Wikipedia says:
Faucet is the most common term in the US, similar in use to "tap" in British English:blob-shrug:
julian
04/29/2022, 6:50 PMtap
operators for quite a while, until I realized that maybe it wasn't meant to denote "knock" (like knock/tap on the door), but rather "faucet".
This may be the result of living in the US where no one says "tap"; they say "faucet". And while "tap" is also a verb, "faucet" is always a noun. To "tap" is to "runTheFaucet" in the US.
Wikipedia says:
Faucet is the most common term in the US, similar in use to "tap" in British English:blob-shrug:
simon.vergauwen
04/30/2022, 9:28 AMjulian
04/30/2022, 7:14 PM