Jörg Winter
12/21/2020, 9:14 PMMickey Donaghy
12/23/2020, 12:26 AMJörg Winter
12/23/2020, 10:32 AMibcoleman
12/27/2020, 10:28 PMSrki Rakic
01/02/2021, 5:44 PMAlfi
01/03/2021, 12:17 AMimport java.lang.Thread.currentThread
import java.lang.Thread.sleep
import java.util.concurrent.CountDownLatch
import kotlin.concurrent.thread
fun main() {
val mainThread = currentThread()
val shutdown = CountDownLatch(1)
Runtime.getRuntime().addShutdownHook(thread(start = false) {
println("Shutdown triggered...")
shutdown.countDown()
mainThread.join()
println("Shutdown completed!")
})
println("Starting...")
sleep(1000) // bootstrap long running resources (e.g. DB Connection, HTTP Server, HTTP Client)
println("Started!")
shutdown.await()
println("Stopping...")
sleep(2000) // graceful shutdown (i.e. request long running resource to stop)
println("Stopped!")
}
I'm wondering how the above translates to Arrow fx.ibcoleman
01/04/2021, 9:28 PMthan_
01/05/2021, 10:12 AMEither::catch
is no longer suspend function and I'm curious what is the reasoning behind that change? I thought the reason was to denote it as a side effect, since throwing is a side effect. That I presume didn't change 😄earroyoron
01/05/2021, 1:40 PMState
I have an object (Customer
) that has his current status as a enum val , I wanna model the posible change from a state to next (as in a state machine pending->...-> review —> onaboarded) and I think using this type is the right way but can’t find a good examplecarbaj0
01/10/2021, 10:35 AMException in thread "main" java.lang.AbstractMethodError: Receiver class com.acv.composeland.ui.arrow.ArrowKt$nullable$2$1 does not define or inherit an implementation of the resolved method 'abstract java.lang.Object invoke(com.acv.composeland.ui.arrow.Either, kotlin.coroutines.Continuation)' of interface com.acv.composeland.ui.arrow.NullableEffect.
at com.acv.composeland.ui.arrow.ArrowKt$main$composition2$1.invokeSuspend(Arrow.kt:75)
at com.acv.composeland.ui.arrow.ArrowKt$main$composition2$1.invoke(Arrow.kt)
at com.acv.composeland.ui.arrow.ArrowKt$nullable$$inlined$suspended$1.invokeSuspend(Effect.kt:25)
at com.acv.composeland.ui.arrow.ArrowKt$nullable$$inlined$suspended$1.invoke(Effect.kt)
at arrow.continuations.generic.SuspendMonadContinuation.startCoroutineUninterceptedOrReturn(SuspendingComputation.kt:88)
at arrow.continuations.Reset.suspended(Reset.kt:27)
at com.acv.composeland.ui.arrow.ArrowKt.nullable(Arrow.kt:88)
at com.acv.composeland.ui.arrow.ArrowKt.main(Arrow.kt:74)
at com.acv.composeland.ui.arrow.ArrowKt$main$2.invoke(Arrow.kt)
at com.acv.composeland.ui.arrow.ArrowKt$main$2.invoke(Arrow.kt)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$1.invokeSuspend(IntrinsicsJvm.kt:205)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
at kotlin.coroutines.jvm.internal.RunSuspendKt.runSuspend(RunSuspend.kt:19)
at com.acv.composeland.ui.arrow.ArrowKt.main(Arrow.kt)
Pratik Tandel
01/13/2021, 1:28 AMFunction1
equivalent for suspending function / coroutines? https://arrow-kt.io/docs/0.10/apidocs/arrow-core-data/arrow.core/-function1/index.htmlMickey Donaghy
01/15/2021, 2:49 AMMonad#fx.monad
is deprecated - apparently fx
will be directly on the concrete datatypes? What does this mean for custom monadic datatypes - do I need to do anything to let me write fx
blocks with my custom monad?Oliver Eisenbarth
01/15/2021, 6:55 PMfix()
calls? I just saw this and wondered, how it's going to look then. Thx and have a nice weekend.ibcoleman
01/17/2021, 10:20 PMvideo▾
kluck
01/18/2021, 4:20 PMIllegalStateException: This job has not completed yet
. Here's a basic example, could you tell me what I'm doing wrong ? Thanks
@Test
fun test() = runBlockingTest {
IO.effect { delay(10000) }.suspended()
}
okarm
01/19/2021, 1:36 PMMarius Kotsbak
01/20/2021, 8:40 AMMarius Kotsbak
01/20/2021, 1:40 PMPueffl
01/23/2021, 2:23 PMMarko Novakovic
01/24/2021, 9:02 AMEither
and Validated
together? Either
for fetching and Validated
for validating data. I have code that parses some data and then I need to perform some check on that data to determine is it valid or not. parsing function return Either
because parsing can fail and I want to validation function to return Validated
based on validation logicAndrei Bechet
01/25/2021, 4:33 PMEither<SomeFailure, Unit>
case? Say I have to set something and don’t care about the result?
We found out the hard way that having Unit
in there could be a potential problem since the compiler does not oblige us to see inside.
thanksBob Glamm
01/27/2021, 3:46 AMOption.fx {
val (a) = Some(1)
val (b) = Some(1 + a)
val (c) = Some(1 + b)
a + b + c
}
raulraja
01/27/2021, 11:22 AMeither {
val a = funThatReturnsEither().bind()
val b = eitherValue.bind()
}
2️⃣ invoke
either {
val a = funThatReturnsEither().invoke() //explicit
val b = funThatReturnsEither()() //implicit
val c = eitherValue()
}
3️⃣ not
either {
val a = !funThatReturnsEither()
val b = !eitherValue
}
4️⃣ other and opinions: (reply in a thread to this message)Stian Brandt
01/31/2021, 10:18 PMfun <F> Runtime<F>.loadNews(): Kind<F, List<NewsItem>> = fx.concurrent {
val response = !effect(context.bgDispatcher) { fetchNews() }
continueOn(context.mainDispatcher)
if (response.isSuccessful) {
response.news().toDomain()
} else {
!raiseError<List<NewsItem>>(response.code().toNetworkError())
}
}.handleErrorWith { error -> raiseError(error.normalizeError()) }
I get a deprecation warning on fx.concurrent: fx: MonadFx<F>' is deprecated. Overrides deprecated member in 'arrow.typeclasses.MonadError'. Fx will be moved to each datatype as a DSL constructor.
What is the correct way to handle this?albertosh
02/01/2021, 9:54 AMCuan
02/01/2021, 3:10 PMarrow.fx.coroutines.retry
the doc's say "The effect is executed once, and if it fails..."
How does it determine failure with the effect?
I've managed to achieve what I want with repeat
and schedule.doUntil { it.isRight() }
but it would make a little more sense to "retry a network request until is succeeds or fails 5 times" than to "repeat a network request until it succeeds or fails 5 times"Chris Paul
02/01/2021, 3:18 PMval result: Either<VdsError, VdsData>
and these error data types:
sealed class VdsError {
object NotFound: VdsError()
object SystemError: VdsError()
}
is there a simple way to map on success, but also on NotFound
, but break out of the mapping if SystemError
?
eg
result.map { data ->
doSomething()
data
}
basically conditionally map some failure circumstances but ignore others?
I thought perhaps a conditional mapLeft would do this, but the problem is that mapLeft
then returns a Left
rather than a Right
and then you immediately exit
hope this makes sense, I'm still quite new to these sort of functional types.dephinera
02/01/2021, 3:31 PMeither1.fold(
ifLeft = { it.left() },
ifRight = { r1 ->
either2.fold(
ifLeft = { it.left() },
ifRight = { r2 -> mapper(r1, r2).right() },
)
}
)
The left type of both eithers is the same. I want to call mapper() if both of eithers are Right
. If one of them is Left
, mapper won't be called. The result type is Either<SameLeftType, ReturnedTypeFromMapper>
.Ifvwm
02/07/2021, 1:58 AMdnowak
02/08/2021, 1:46 PMIO.handleError
in new Fx based on suspend
functions?dnowak
02/08/2021, 1:46 PMIO.handleError
in new Fx based on suspend
functions?stojan
02/08/2021, 2:22 PMEither.catch { mySuspendFun() }.handleErrorWith
dnowak
02/09/2021, 11:54 PMEither.catch
as I understand should be used to execute side effect - similar to “legacy” IO.effect
. Before running final IO
I was always adding handleError
to be sure that none of unexpected exceptions will escape.stojan
02/10/2021, 7:44 AM