I want to copy a potentially huge file from one place to another (for example, but not limited to, the local filesystem). In order to decouple the reading from the writing, my copy flow has steps to perform each task:
The reading step returns a…
Disclaimer upfront: Recently, my interest in functional programming has grown and I've been able to apply the most basic approaches (using pure functions as much as my knowledge and working environment permits) in my job. However, I'm still very…
Given this (extremely simplified) code :
@optics
data class MigrationStatus(val token: String?)
val m = MigrationStatus(null)
I can call
val m1 = MigrationStatus.token.modify(m) { "some token" }
But as the argument type is a non nullable String,…
According to Arrow's Javadoc there are three ways of binding over a monad:
/**
* All possible approaches to running [Kind] in the context of [Fx]
*
* ```
* fx {
* val one = just(1).bind() // using bind
* val (two) = just(one + 1) // using…
I am trying to use arrow in kotlin
Arrow has three functions
IO {}
IO.fx {}
IO.fx { !effect}
I want to know the difference between these. I know IO.fx and IO.fx {!effect} help us use side effects but then whats the difference between the two and…
I have a few specialized classes that I would like to create using Kotlin and Arrow and they will wrap around an Arrow Either monad. I've created the following code to use Kotlin's delegation, but I am wondering whether it can be simplified or made…
I have a call chain of some methods, where I pass a context via a Kleisli. Basically I want to pass a context down to the db access layer, but I want to access this context everywhere in between.
The following example works perfectly. My problem…
I come across below generic function which takes two Either type and a function as an argument. If both arguments are Either.Right then apply the function over it and returns the result, if any of the argument is Either.Left it returns…
I'm learning functional programming in Kotlin using arrow library and I come across below strange behaviour of fold function of Either type (at least for me).
import arrow.core.*
import arrow.syntax.function.pipe
object UserService {
fun…
In Android network operations are usually done within ViewModel. This ensures that even when the Activity or Fragment is recreate (for example when device is rotated), the network call keeps going and not cancelled.
Now to submit the result of the…
Is is possible to cancel an (Arrow-Kt) IO?
In RxJava whenever I do observable.subscribe({ // handle success },{ // some errohandling }), I am given a Disposable which I could call Disposable.dispose() on.
Similar with coroutines, doing…
ArrowKt has deprecated Try since it promotes eager execution of effects and it recommends to use suspend constructors.
But how should I handle following case where I do want eager execution on purpose without using traditional try-catch.
fun…
I've been using Arrow Kotlin quite a lot recently but I'm still confused on how to map a list of options to their values. For example:
val listOfStrings: List = listOf
>().map { /* ? */ }
Currently I'm doing it like this:
val…