https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
arrow
  • b

    Bart Kleijngeld

    03/22/2022, 2:56 PM
    I'm facing a simple task, but struggle to solve it elegantly. (To clarify: performance is not an issue). I have two
    Set<X>
    collections, and I want to see if they contain equal items. The challenge is that this equality must be tested by some external
    isomorphic
    function (which takes two arguments of type
    X
    ) instead of the standard equality operator. Can someone point towards helpful ideas or tools in Kotlin/Arrow?
    r
    22 replies · 2 participants
  • r

    rcd27

    03/22/2022, 6:31 PM
    Greetings. Assuming I have:
    Map<Int,List<ONE>>
    Map<Int,List<TWO>>
    ...
    Map<Int,List<N>>
    Is there any "instrument" I can zip it to
    Map<Int, Tuple<ONE,TWO,...,N>>
    where ints represent unique numbers which present in each Map?
    s
    5 replies · 2 participants
  • p

    pepe

    03/23/2022, 3:37 PM
    Hi everyone! I'm trying to do something like this with only Arrow Core
    Option.fromNullable(nullableValue).mapNotNull(::f1).flatMap(::f2)
    where f1 is
    suspend (String) -> String?
    and f2 is
    suspend (String) -> Option(Whatever)
    , is this supported?
    s
    3 replies · 2 participants
  • f

    Francesco Bonnì

    03/29/2022, 7:08 AM
    Hi everyone, I added Arrow on my KMP project and used it in the commonMain part. When I use the generated framework/aar, I’m experiencing some NoClassDefFoundError Either.kt in the android application (iOS run without any problem), if I add the Arrow dependency on android I solve the problem but asap will be rise another NoClassDefFoundError for a simple kotlin file inside the project, did somebody have the same experience or know where I should check to solve the problem?
    r
    s
    5 replies · 3 participants
  • t

    Tiberiu Tofan

    03/30/2022, 11:11 AM
    Hi everyone, I was looking over the differences between suspended computation blocks and the eager variant, and my intuition is that the eager variant is not pure. E.g.
    either {}
    vs
    either.eager {}
    . I admit that I didn’t fully understand the implementation for the eager variants. Is my assumption correct? Would this be an important argument for using the suspended variant?
    s
    p
    56 replies · 3 participants
  • s

    Satyam Agarwal

    03/30/2022, 12:00 PM
    When using bind inside either blocks, to simulate a failure, I sometimes do MyError.left().bind(). This leads to compiler warning me like :
    Returning type parameter has been inferred to Nothing implicitly. Please specify type arguments explicitly to hide this warning. Nothing can produce an exception at runtime.
    What are the implications of this, apart from readability that
    MyError.left().bind()
    is not clear in what the RHS can be. iirc, its not trivial to remove these errors, they can only be suppressed. Is there any work being done in fixing this ? Also,
    MyError.left().bind()
    is this recommended approach ? I often use filterOrOther to avoid warnings.
    m
    s
    +1
    14 replies · 4 participants
  • r

    rcd27

    04/03/2022, 11:32 AM
    Trying to remember one video about Functional Programming, but can't. Maybe you can help. So this was some kind of conference, seems like in 00's or early 10's and a man was showing Functional approaches in writing UI programs. He was combining different shapes and surfaces for rendering a simple 3D object(sphere for example) in his GUI.
    p
    2 replies · 2 participants
  • g

    gabib

    04/04/2022, 2:47 PM
    Hi everyone, I had a use case recently where I had to return left in an either if the right value was not null. So I ended up writing an extension function for that:
    inline fun <E, B> Either<E, B?>.leftIfNotNull(f: () -> E): Either<E, Nothing?> = flatMap { it.rightIfNull { f() } }
    Is there something that might have helped in Arrow and I've missed it?
    t
    2 replies · 2 participants
  • s

    Satyam Agarwal

    04/06/2022, 11:58 AM
    Hei ! I can’t find the thread back, so I’ll ask again. Why CancellationException is considered as Fatal error, and thus not being caught in Either.catch ? Since my operations inside bracketCase are wrapped in Either, I have to explicitly catch CancellationException, to rollback my transactions on ExitCase.Cancelled
    s
    s
    28 replies · 3 participants
  • e

    Emil Kantis

    04/06/2022, 3:19 PM
    I’m looking for a method to do
    List<ValidatedNel<E, A>>
    ->
    ValidatedNel<E, List<A>>
    , is there any such method? 🙂
    a
    4 replies · 2 participants
  • j

    jeff

    04/06/2022, 4:38 PM
    Let's say I have 2 classes A & B, with fields of the same name but different types. For each field I have an Iso from one type to the other. Is there an easy/concise way to turn those into an Iso<A, B>?
    s
    1 reply · 2 participants
  • p

    Pavel

    04/06/2022, 5:49 PM
    Hey guys, I have a question regarding Arrow Fx: how stable is it (will the API change/be deprecated)? Is it production ready in terms of quality?
    s
    j
    7 replies · 3 participants
  • a

    Alan B

    04/13/2022, 5:34 PM
    Hello all! Are there any other suggested resources for understanding the Arrow library, or the concepts used within? Many of the terms (function names and class names) are foreign to many new to the functional world. A high percentage of the functions/classes and usage are not documented. It seems there is an assumption of previous knowledge to utilize the libraries. Is there another documentation source from another library that perhaps this pulled its ideas from (Scala?) for those new to functional programming understand what these mean and are use for? I've been trying to move a team forward but it's just to difficult to be bombarded with so many questions due to the lack of resources, and the team has already pulled back and are devolving back to old habits.
    t
    s
    5 replies · 3 participants
  • i

    iguissouma

    04/15/2022, 9:04 AM
    Hello, I’m updating to latest version of arrow, I have a problem with one method. What’s the equivalent of this method using latest arrow version, thanks in advance.
    /**
     * Given a path as string dot-separated component, extracts the item found at that path location.
     * Eg.:
     * Given m = mapOf("p1" to mapOf("p2" to "value_1_2"))
     * Then m.readPath("p1.p2") -> Option["value_1_2"]
     */
    inline fun <reified T> Map<String, Any>.readPath(pathComponents: String): Option<T> {
        val extract = { v: Any, p: String -> (v as? Map<*, *>)?.get(p).toOption() }
        return pathComponents.split(".").foldM(Option.monad(), this, extract).fix().flatMap { (it as? T).toOption() }
    }
    s
    1 reply · 2 participants
  • r

    Ron S

    04/24/2022, 2:58 PM
    I love the NonEmptyList class of the arrow-core library. It statically ensures the presence of at least one element. What do you think about introducing a NonEmptySet class extending the Set interface? Haskell seems to have an equivalent too.
    s
    3 replies · 2 participants
  • i

    Ivan Dugalic

    04/24/2022, 4:20 PM
    I have upgraded to arrow 1.1.2, and switched from
    either
    to
    Effect
    . I like it BTW, it is a nice abstraction IMHO. But I have some issues. It is a multiplatform project and issue might not be related to Arrow, but it emerged once I switched to
    Effect
    . It looks related to
    native
    target(s) only. More in the thread …
    s
    r
    70 replies · 3 participants
  • p

    phldavies

    04/24/2022, 7:19 PM
    Are there any release notes or announcements for 1.1.0/1.1.2 releases?
    j
    y
    2 replies · 3 participants
  • m

    Mervyn McCreight

    04/26/2022, 9:13 AM
    Is it safe to use
    1.1.2
    for now, coming from a pure jvm-project, or should I wait for the official announcement and release blogpost before updating? 🙂
    :plus-one: 1
    s
    1 reply · 2 participants
  • d

    Dirk

    04/26/2022, 2:35 PM
    Hi, I have a problem to use Arrow in my JS project. I took the versions from the sample project (https://github.com/arrow-kt/Arrow-JS-Template) and I get a compiler error when building. Has anyone experienced this before and has any idea how I can fix it. The sample project can be built and also runs in the browser.
    s
    5 replies · 2 participants
  • c

    christophsturm

    04/27/2022, 8:11 AM
    is there a way to generate arrow lenses at compile time without annotating the class? I want to use arrow just for my unit tests and no arrow deps in main sources.
    s
    3 replies · 2 participants
  • t

    thanh

    04/27/2022, 9:04 AM
    Can we optimize this
    futureOr
    function:
    suspend fun fu(i: Int): Boolean = TODO()
        suspend fun futureOr(fs: List<Int>): Boolean =
            fs.parTraverse { fu(it) }.reduce { acc, b -> acc || b }
    Now it needs to wait for all of suspend function completed. But we know that if there is one of the
    fu(it)
    return
    false
    we can return
    false
    and cancel the rest. Not sure how to do it nicely here.
    s
    j
    12 replies · 3 participants
  • c

    christophsturm

    04/27/2022, 1:15 PM
    can i combine 2 lensen to something that sets and gets 2 values?
    s
    7 replies · 2 participants
  • y

    Yannick Lazzari

    04/27/2022, 4:13 PM
    Hi all. Question regarding Either and Exception handling. Given we still live in an imperfect world that’s not fully functional, there often comes a time in a program when you need to bridge between the functional parts of your program and imperative parts that still rely on Exceptions being thrown to manage control flow. I find myself leaning on an extension function that looks like this:
    fun <A,B> Either<A, B>.throwException(f: (A) -> Unit): Unit = when (this) {
        is Either.Left -> f(this.value)
        else -> Unit
    }
    which I then use like this:
    val someResult: Either<SomeErrorADT, String> = ...
    someResult.throwException { 
      when (it) {
        SomeErrorADT.Error1 -> throw SomeException1("...")
        SomeErrorADT.Error2 -> throw SomeOtherException("...")
      }
    }
    Is there an existing function or extension function that exists in Arrow that kind of does the same thing that I’m not seeing?
    p
    s
    4 replies · 3 participants
  • j

    Jonathan De Leon

    04/27/2022, 7:18 PM
    Using
    Schedule
    to repeat an operation. Is there a way to get the delay after adding jitter to the schedule. Better yet, is there a way to get how much time has elapsed since the start of the schedule.
    Schedule.exponential<SomeResult>(someConfigDelay)
                .jittered()
                .whileOutput { it < someConfigMaxDelay }
                .logOutput { log.debug("Current delay: $it - ${it.inWholeNanoseconds} ns") }
    s
    5 replies · 2 participants
  • p

    phldavies

    04/28/2022, 11:40 AM
    I’ve been finding myself using this recently:
    internal infix fun <A, B> Resource<A>.flatTap(resource: (A) -> Resource<B>): Resource<A> =
        flatMap { a -> resource(a).map { a } }
    which allows for constructs such as
    fun CoroutineScope.myProcessor(database: Database) = resource {
        MyProcessor(coroutineContext, database)
    } release {
        it.close()
    } flatTap {
        resource { it.backgroundWorker() } release Job::cancel
    }
    Effectively allowing for similar usages as
    tap {}
    but with a teardown/release.
    👍 1
    s
    7 replies · 2 participants
  • s

    Satyam Agarwal

    04/28/2022, 2:38 PM
    Hei. I wonder if we arrow has wrappers on collection apis to always return Nel instead of List. For example nonEmptyListOf(1, 1).distinct() will always be non empty, but because of kotlin apis, i get back List. This is uncomfortable. to ensure I am working with an nel, I often end-up converting list to nel. It would’ve been nice to not do that.
    s
    4 replies · 2 participants
  • p

    phldavies

    04/29/2022, 1:19 PM
    I think I’m encountering a bug in
    Resource.parZip
    when `parZip`ing a `parZip`’d resource 🙂
    suspend fun main() = int(1)
        .parZip(int(2), Int::plus)
        .parZip(int(3), Int::times)
        .use { println("using $it") }
    
    private fun int(n: Int) = resource {
        n.also { println("acquiring $it") }
    } release {
        println("releasing $it")
    }
    outputs
    acquiring 2
    acquiring 1
    acquiring 3
    using 9
    releasing 3
    and never releases 1 and 2
    s
    18 replies · 2 participants
  • y

    Yannick Lazzari

    04/29/2022, 4:01 PM
    Hi all. Is there a good “Pet Store” example application that anybody could share, one that shows an opinionated view of when and how to use the various Arrow types (or not)? I.e. an application that actually performs a more real-life like business function? Possibly one that’s maintained by the maintainers of the Arrow library itself? Surely there are assumptions/expectations of how the various APIs should be used when they are authored, so I’d be curious to see more on that. I think it would be helpful when getting started. I browsed all the repos in the Arrow Github org and nothing stood out. Thank you!
    s
    s
    4 replies · 3 participants
  • p

    phldavies

    04/29/2022, 4:59 PM
    @simon.vergauwen it seems like the new
    resource { }
    DSL releases resources in the wrong order - see 🧵
    s
    22 replies · 2 participants
  • j

    julian

    04/29/2022, 6:50 PM
    I had been puzzled by the name of the
    tap
    operators for quite a while, until I realized that maybe it wasn't meant to denote "knock" (like knock/tap on the door), but rather "faucet". This may be the result of living in the US where no one says "tap"; they say "faucet". And while "tap" is also a verb, "faucet" is always a noun. To "tap" is to "runTheFaucet" in the US. Wikipedia says:
    Faucet is the most common term in the US, similar in use to "tap" in British English
    :blob-shrug:
    s
    3 replies · 2 participants
Powered by Linen
Title
j

julian

04/29/2022, 6:50 PM
I had been puzzled by the name of the
tap
operators for quite a while, until I realized that maybe it wasn't meant to denote "knock" (like knock/tap on the door), but rather "faucet". This may be the result of living in the US where no one says "tap"; they say "faucet". And while "tap" is also a verb, "faucet" is always a noun. To "tap" is to "runTheFaucet" in the US. Wikipedia says:
Faucet is the most common term in the US, similar in use to "tap" in British English
:blob-shrug:
s

simon.vergauwen

04/30/2022, 9:28 AM
The functionality was originally also requested with the name tap as a suggestion, and many contributors were already familiar with that name from Scala. I think the name tap comes from the fact that it _tap_s/touches the value inside the monad, but doesn't change or take out the value. It just taps / peeks it
Scala names are typically US based Cats-effects: cancelable Kotlin: cancellable
j

julian

04/30/2022, 7:14 PM
Interesting... Thanks for indulging my musings 😄
View count: 6