dave08
02/16/2023, 12:08 PM?.
and ?:
be overridable operators for a non-null type... then it could avoid all the `bind()`s and `flatMap`s and hacks that Arrow is doing... did someone ever propose such a thing? (or maybe some similar operator if people might find it too confusing and think that they're dealing with nullables.)João Gabriel Zó
02/16/2023, 5:23 PMResult<Unit>
the best thing to do here or is there anything else in the std library?dave08
02/20/2023, 10:43 AMRuntime.getRuntime().addShutdownHook(hook)
, is that only SIGINT? It seems like in your video it was clearly using SIGINT, but in my current version not...Mazhar Ibna Zahur
02/23/2023, 10:58 AMNorbi
02/25/2023, 9:16 AMNorbi
03/01/2023, 9:26 AMraise()
functionality and I try to find a library function similar to the following hypothetical orElse()
:
context(Raise<String>)
fun f1() = 1
context(Raise<String>)
fun f2(): Nothing = raise("error")
suspend inline fun <R, A> Effect<R, A>.orElse(noinline block: suspend (R) -> A) =
fold(
recover = block,
transform = ::identity
)
val v1 = effect { f1() }.orElse { 33 }
assertEquals(1, v1)
val v2 = effect { f2() }.orElse { 33 }
assertEquals(33, v2)
I use arrow 1.1.6-alpha.36.
Thanks.Kristian Nedrevold
03/07/2023, 9:18 PMdori
03/10/2023, 10:24 AMjean
03/17/2023, 11:26 AMdata class SomeData(val someValue: String) {
companion object {
fun someFunction() {}
}
}
// OR
data class SomeData(val someValue: String) {
companion object
}
fun SomeData.Companion.someFunction() {}
João Gabriel Zó
03/17/2023, 6:00 PMfunctionOne: Result<Something>
functionTwo: Result<Unit>
I’ll only call functionTwo if the first one returns a Success, and return a Result<Something>
in case both of them return a Success.
What’s the best way to do it using std lib? I thought the nested folds and maps and ifs turned out a bit uglyNorbi
05/19/2023, 7:58 AMNathan Bedell
06/27/2023, 4:19 PM(State, Action) -> State
, but my question was more about how to actually action this reducer to do stuff with the UI.
Currently we are taking in a Flow of Actions, an initial state, and updating that state (as a StateFlow) by launching a collect block on the action flow to update the state. The body of the collect statement on the flow is synchronized with a mutex so actions should (I was hoping anyway) get executed in order sequentially.
In practice, this seems to work. However, I've noticed in tests this sometimes fails, which makes me wonder if my setup of this is actually optimal. I was thinking maybe a channel of user actions might be more robust, but open to ideas!Uberto Barbini
10/08/2023, 12:21 AMreactormonk
11/22/2023, 6:31 PMreduce
where I can pass the initial acc
?reactormonk
11/22/2023, 6:34 PMS
of the result even come from? O.oYoussef Shoaib [MOD]
01/13/2024, 10:23 PMJun Sekine
01/15/2024, 5:49 AMThomas
01/17/2024, 2:46 AMfun <A, B, R> Collection<A>.combine(other: Collection<B>, transformation:(A, B)->R): List<R> =
ArrayList<R>(this.size * other.size).also{
for(a in this){
for(b in other){
it.add(transformation(a, b))
}
}
}
Example:
fun main(){
println(
listOf(1,2,3).combine(listOf("a", "b", "c")){a, b -> "$a-$b"}
)
}
Output:
[1-a, 1-b, 1-c, 2-a, 2-b, 2-c, 3-a, 3-b, 3-c]
Thomas
01/17/2024, 2:51 AMcartesianProduct
?Christopher Hübner
02/05/2024, 2:43 PMreactormonk
02/05/2024, 3:04 PMChristopher Hübner
02/15/2024, 8:41 AMKev
03/19/2024, 10:59 AMwith(..)
clause?Emre
04/24/2024, 4:37 PMreactormonk
05/25/2024, 6:47 PMYoussef Shoaib [MOD]
06/04/2024, 1:40 PMsuspend
and a Channel
to pass a value "backwards" in time, but I don't trust that it's actually "correct"reactormonk
06/19/2024, 7:28 AMwhen
on two items? Use a Pair
and deconstruct using to
?Pablichjenkov
06/27/2024, 10:51 PMalgebraic data types
?
What's the relationship with algebra?reactormonk
11/28/2024, 12:51 PMUlrich Schuster
12/25/2024, 1:36 PMf(x: X, (X) -> Y): Y
that takes some argument x: X
and a function (X) -> Y
. And I have a concrete function with receiver, say Int.makeY(x: X): Y
. I would like to partially apply makeY
to a given receiver and pass it to f
, like
val foo = 5
f(x) { foo::makeY }
However, this results in an ArgumentTypeMismatch compilation error, stating that Y
was expected instead of the provided function reference. Am I simply making a mistake in my declaration, or is it simply not possible to pass a partially applied function with receiver as reference?