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
0
votes
1 answer

How to abstract from Try in arrow-kt

I'm using Arrow in my Kotlin backend project. I have repositories like this: interface UserRepository { fun user(username: String): Try> } Now I want to go step further and abstract from concrete Try type with returning Kind
Izbassar Tolegen
  • 1,990
  • 2
  • 20
  • 37
0
votes
2 answers

How to use arrow's type classes?

I'm trying to get familiar with the arrow-kt library, but I'm to dumb to get the easiest thing done: Using one of the built in type classes, namely 'Show' I tried it with kapt using the @extension annotation and kapt itself is generating the…
0
votes
1 answer

Is there any function like ap2, ap3 in arrow-kt?

I saw scala code using cats in this post. val a = Some(7) val b = Some(9) Applicative[Option].ap2(Some(add))(a,b) And I tried migrating this code to kotlin and arrow like following. Option.applicative() .tupled(Some(7), Some(9)) …
galcyurio
  • 1,776
  • 15
  • 25
0
votes
2 answers

Kotlin arrow transform a List of failures to a Failure of a list

How can I transform the following: List> to: Try> Using kotlin and the functional library arrow (0.8.2). I would like to wrap it in a custom exception. It does not matter which one of the 'String' failed. Update: As the…
ielkhalloufi
  • 652
  • 1
  • 10
  • 27
0
votes
2 answers

Are there elegant ways to turn a List into a NonEmptyList in kotlin and arrow?

fun main() { val list = listOf(1, 2, 3, 4, 5) if (list.isNotEmpty()) { Nel(list[0], list.subList(1, list.lastIndex)) } } According to arrow documents, it seems be able to do it through Semigroup or Monad binding. However,…
galcyurio
  • 1,776
  • 15
  • 25
0
votes
1 answer

Kotlin + Arrow + Gson = None?

I have a model in Kotlin of a simple library of Books and Borrowers where a Book is checked out if it has a Borrower. I use Arrow Option to encode the absence/presence of a Borrower: data class Borrower(val name: Name, val maxBooks: MaxBooks) data…
ericky
  • 1,641
  • 2
  • 14
  • 16
0
votes
1 answer

Kotlin compose list of functions

Currently I am using compose from a library called arrow which has it defined this way. inline infix fun ((IP) -> R).compose(crossinline f: (P1) -> IP): (P1) -> R = { p1: P1 -> this(f(p1)) } What I am trying to do is compose functions…
Bads
  • 774
  • 3
  • 8
  • 20
0
votes
2 answers

Smart cast an Arrow-kt Option

I am trying to smart cast an Option from any Any variable so that I can determine if the Option is empty however the IDE is indicating that Option<*> could not be smart cast because it is declared in a different module. fun hasEmptyValue(column:…
Mark Ashworth
  • 164
  • 12
-1
votes
1 answer

Best approach with arrowKt and repositories

I have an usecase on my work and I want to discuss with you what should be the best approach to do it. In repository functions that should finds only one line what should be the best approach, return left when entity is not found on database or…
1 2 3
8
9