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
2
votes
2 answers

kotlin when expression autocast

I would like the following kotlin code to work: val result: Try> = Success(Some("test")) val test = when { result is Success && result.value is Some -> result.value.t // not working result is Success && result.value is None…
ielkhalloufi
  • 652
  • 1
  • 10
  • 27
2
votes
1 answer

Generating lenses with Kotlin Arrow library

I'm reading "Functional Kotlin" which describes the generation of lenses using annotations. @lenses import arrow.lenses import arrow.optics.Lens import arrow.optics.modify typealias GB = Int @lenses data class Memory(val size: GB) @lenses data…
Johan Vergeer
  • 5,208
  • 10
  • 48
  • 105
1
vote
1 answer

How to build a Lens to "filter and modify" elements of list element? Using Arrow Optics

Using kotlin lib Arrow/optics Is there a way to build a lens to filter and set/modify a element of list property? like this code - @optics data class Order(val code: String, val lines: List){ companion object } @optics data class Line(val…
Jason
  • 546
  • 1
  • 4
  • 11
1
vote
1 answer

How to call Arrow.kt function returning basically Either but using multiple context receivers

Arrow.kt docs point out that instead of: fun get(): Either we can use context(Raise) fun get(): Res And we can even have multiple context receivers. Imagine we have two error types class Err1 class Err2 And a function that has two…
1
vote
1 answer

Kotlin Arrow EffectScope.shift() implementation throws exception?

When looking at arrows documentation about functional error handling one of the reason listed to avoid throwing exceptions is performance cost (referencing The hidden performance costs of instantiating Throwables) So it is suggested to model…
rascio
  • 8,968
  • 19
  • 68
  • 108
1
vote
1 answer

How do you add/remove an element of immutable list using Arrow Optics?

I have a complicated, immutable data structure that includes simple fields, but also maps and lists in the hierarchy. Maybe I'm just not reading the documentation closely enough, but there doesn't seem to be an easy way to modify the list as a whole…
Todd O'Bryan
  • 2,234
  • 17
  • 30
1
vote
1 answer

How can you paralellize the processing of File InputStreams in Kotlin / Arrow?

I am processing large Files, having a list of them: val originalFiles: List I need to read the InputStream of each file, process it, and write it to another processedFile. For the sake of simplicity let's assume I just read the original…
codependent
  • 23,193
  • 31
  • 166
  • 308
1
vote
1 answer

Kotlin Arrow - 'option' is deprecated. Deprecated in favor of the Effect or EagerEffect Runtime

I'm getting below depreciation warning in arrow 1.1.2, could anyone please tell me what's the correct replacement for this? [DEPRECATION] 'invoke(crossinline suspend OptionEffect<*>.() -> A?): Option' is deprecated. Deprecated in favor of the…
Vencat
  • 1,272
  • 11
  • 36
1
vote
1 answer

Why does `EffectScope.shift` need the type parameter `B`?

The move to the new continuations API in Arrow brought with it a handy new function: shift, in theory letting me get rid of ensure(false) { NewError() } or NewError().left().bind() constructs. But I'm not sure how to properly use it. The…
Kolja
  • 1,197
  • 9
  • 17
1
vote
1 answer

arrow validation more then 10 fields

all I have a question how can I validate more then 10 values with arrow in kotlin. fun CreateEventDTO.validate(): Validated = name.isEventNameValid() .zip( about.isAboutValid(), …
Victor Orlyk
  • 1,454
  • 2
  • 15
  • 27
1
vote
1 answer

Mixing Eithers and other exceptions inside an either.eager

I have code I've written inside an either.eager return either.eager { val objList = service.getObjs().bind() val obj = objList.find{...} ?: throw MyException.notFoundException() …
Somaiah Kumbera
  • 7,063
  • 4
  • 43
  • 44
1
vote
1 answer

is ValidatedNel arrow-kt in v1.0 still an Applicative (Functor)?

I understand that in previous versions of Arrow-Kt was an instance of the Applicative typeclass. In the current version 1.0.x, most typeclasses are no longer present/visible (to make the library more accessible, I presume?). There are some excellent…
Chris
  • 408
  • 2
  • 10
1
vote
1 answer

Handling an Arrow-kt Either inside a map

My question is somewhat related to Kotlin arrow-kt Flatten nested Either, but also not exactly. I have a list that I map through, and within this map I call a function that returns an Either. If the Either contains an error, I need to quit right…
Somaiah Kumbera
  • 7,063
  • 4
  • 43
  • 44
1
vote
2 answers

Processing async results with Arrow-kt and Kotlin

I have two async function calls to external systems returning Either and need to combine their results. Being a beginner in functional programming in Arrow-Kt, I am wondering which is the best way of accomplishing this…
macnixde
  • 213
  • 1
  • 9
1
vote
2 answers

Can I use Kotlin Arrow-lib with Quarkus in native builds

I started a new Kotlin project and i want to use the arrow-kt core Lib in combination with Quarkus (1.12.2). I want to use the native compilation feature of Quarkus with the GraalVM. My first thought was that arrow is a simple lib without reflection…
Alex
  • 80
  • 6
1 2 3
8 9