Questions tagged [arrow-kt]

Λrrow is a library for Typed Functional Programming in Kotlin

Related to the Arrow library for Kotlin. https://arrow-kt.io/

129 questions
1
vote
1 answer

Exceptions thrown while generating a sequence

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…
1
vote
1 answer

FP patterns for combining data from different sources (preferrably in Kotlin and Arrow)

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…
1
vote
1 answer

Arrow lens won't let me set a nullable property to null

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,…
xlecoustillier
  • 16,183
  • 14
  • 60
  • 85
1
vote
1 answer

Destructuring instead of .bind() doesn't work in an Arrow Monad comprehension

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…
codependent
  • 23,193
  • 31
  • 166
  • 308
1
vote
1 answer

Difference between Kotlin arrow IO, IO.fx, IO !effect

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…
Legendary_Hunter
  • 1,040
  • 2
  • 10
  • 29
1
vote
1 answer

Kotlin - Composition of multiples IO

I'm new to Kotlin's Arrow Framework and I have a couple of questions: Lets suppose fun getUser(id: Int): IO> fun getCards(user: User): IO> fun getUserAndCards(id: Int): IO>>> = IO.fx { when…
Quarktum
  • 669
  • 1
  • 8
  • 26
1
vote
2 answers

Is it possible to use Kotlin's by-delegation with an existing class/object (i.e.Arrow's Either)?

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…
A Bit of Help
  • 1,368
  • 19
  • 36
1
vote
2 answers

How can I access the context in every function of a call chain with Kleisli?

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…
breucode
  • 13
  • 2
1
vote
2 answers

Cast away nested Option in Kotlin arrow

I have a value with below type in my data class Option>>>> How would I access the right-most Option. I have tried with when expression like below when(Option
Vencat
  • 1,272
  • 11
  • 36
1
vote
1 answer

Understanding Validated.applicative in kotlin arrow library

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…
Vencat
  • 1,272
  • 11
  • 36
1
vote
1 answer

return type of Either.fold() in Kotlin arrow library

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…
Vencat
  • 1,272
  • 11
  • 36
1
vote
1 answer

How implement Arrow Kt with Android ViewModel?

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…
Archie G. Quiñones
  • 11,638
  • 18
  • 65
  • 107
1
vote
1 answer

How to cancel arrow-kt IO?

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…
Archie G. Quiñones
  • 11,638
  • 18
  • 65
  • 107
1
vote
2 answers

ArrowKt Try alternative for eager execution

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…
Ali Arslan
  • 1,027
  • 10
  • 24
1
vote
3 answers

Map list of Options to list of Strings

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…
m0skit0
  • 25,268
  • 11
  • 79
  • 127
1 2 3
8 9