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…
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…
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…
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…
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…
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…
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…
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…
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(),
…
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()
…
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…
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…
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…
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…