kioba
08/16/2020, 1:20 PMIO and ObservableK from my library module and standardize calls around F using Concurrent<F>.
Arrow version 0.11.0-SNAPSHOT
usage of fx mentions that
fx: MonadFx<F>' is deprecated. Overrides deprecated member in ‘arrow.typeclasses.MonadError’. Fx will be moved to each datatype as a DSL constructor.What would be the correct usage for fx in this case?
kioba
08/16/2020, 1:21 PMoverride fun getShowImage(id: Int): IO<ShowImageResponse> =
tmdbService.getShowImage(id)
.defer(IO.async())
.flatMap { it.unwrapBody(IO.applicativeError()) }
override fun getShowImageStream(id: Int): ObservableK<ShowImageResponse> =
tmdbService.getShowImage(id)
.defer(ObservableK.async())
.flatMap { it.unwrapBody(ObservableK.applicativeError()) }
Moving the separate implementation into:
fun <F> Concurrent<F>.getShowImage(id: Int): Kind<F, ShowImageResponse> =
tmdbService.getShowImage(id).async(fx.M)
.flatMap { it.unwrapBody(fx.M) }kioba
08/16/2020, 1:25 PMsimon.vergauwen
08/17/2020, 11:12 AMfx in favor of computational blocks, and replacing F for continuations completely.
This looks however something that I'd implement over Fx and instead using MonadDefer we'll introduce integration packages such as can be found in KotlinX Coroutines to properly integrate cancellation.
fun observableEffect(f: suspend () -> A): Observable<A>
This will also result in a more straight-forward API since the typeclasses were never really properly prepared for streaming.simon.vergauwen
08/17/2020, 11:13 AMfx, it seems you're trying to get hold of a typeclass instance but it's not letting you? 🤔kioba
08/17/2020, 11:20 AMit seems you’re trying to get hold of a typeclass instance but it’s not letting you? 🤔Yes, that is correct. I am using
fx to reach the TypeClasses of F higher kinded type.simon.vergauwen
08/17/2020, 11:23 AMConcurrent as Async, since interface Concurrent<F> : Async<F> which through Bracket also extend MonadDefer.kioba
08/17/2020, 11:23 AMsuspend () -> A and Kind<F, A> is the same and the suspend function could replace Fsimon.vergauwen
08/17/2020, 11:23 AMsimon.vergauwen
08/17/2020, 11:24 AMsuspend is however a cheaper encoding, and will allows us to get rid of Kind etc without having to rely on compiler plugins.simon.vergauwen
08/17/2020, 11:25 AMkioba
08/17/2020, 11:26 AMsuspend Functor<F>.myfunction() : Asimon.vergauwen
08/17/2020, 11:27 AMContinuation.
Computation typeclasses such as Monoid, Align, etc will all still be relevant since those don't abstract over control flow but over logic/computations.