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
  • s

    stojan

    12/15/2021, 12:12 PM
    what would be a way to "fork" an operation (suspend function) to a different scope with arrow-fx-coroutines? .... let's say on Android, I trigger an action from a ViewModel (using
    viewModelScope
    ) which calls a suspend function in a Repository layer..... I want to suspend until the repo function executes, but also if the
    viewModelScope
    is canceled I don't wanna cancel the repository operation. I wanna tie the repository operation to an application level scope instead
    y
    • 2
    • 1
  • r

    raulraja

    12/15/2021, 4:05 PM

    https://www.youtube.com/watch?v=IDMmmrRhUvQ▾

    🙌 13
    :arrow: 14
    • 1
    • 1
  • p

    Peter

    12/15/2021, 5:16 PM
    nice work @simon.vergauwen @Alejandro Serrano Mena!
    ➕ 5
    a
    s
    g
    • 4
    • 17
  • s

    simon.vergauwen

    12/16/2021, 1:43 PM
    There were also a couple questions about Arrow Optics code generation in the last months. We currently have a KSP port of the kapt version as a SNAPSHOT on the latest version of Google’s KSP. You can find an example of how it’s set up in the linked
    build.gradle.kts
    . If you try it, and come across anything broken please let us know 🙂 https://github.com/arrow-kt/backend-arrow-example/blob/86e3bf459a8eda06cd41a17105f807202698cea4/build.gradle.kts#L38
    👍 4
    :party-parrot: 1
    👍🏼 1
    n
    t
    • 3
    • 7
  • l

    Lukasz Kalnik

    12/17/2021, 2:52 PM
    I have just updated my Arrow fork to the latest
    main
    and when I try to build
    arrow-libs
    I get the error:
    Project directory '/Users/lukasz/projects/arrow/arrow-libs' is not part of the build defined by settings file '/Users/lukasz/projects/arrow/settings.gradle.kts'. If this is an unrelated build, it must have its own settings file.
    t
    • 2
    • 2
  • i

    ivanmorgillo

    12/20/2021, 10:21 AM
    Hi all, I'm probably holding it wrong or/and I missed some steps in the evolution of the library I know that
    CoProduct
    was removed at some point, but wasn't it replaced by
    Union
    ? Which dependency do I need to get
    Union2
    Union3
    etc?
    r
    • 2
    • 2
  • a

    abendt

    12/20/2021, 2:27 PM
    Hey folks, when i import my Arrow fork into IntelliJ it does not seem to be possible to run the Kotest tests directly from IntelliJ (screenshot #1 gutter icon is not displayed). As this works in other projects i assume my general IntelliJ setup + plugin is correct (see screenshot #2) Is there any further setup i need to do in IntelliJ to be able to run tests directly?
    j
    s
    s
    • 4
    • 11
  • d

    dnowak

    12/21/2021, 3:38 PM
    Hi, what is the “nicest” way to partially apply more than a few parameters?
    p
    h
    +2
    • 5
    • 12
  • d

    Dutch

    12/22/2021, 5:52 PM
    Hey everyone, I'm trying to create my first plugin with Arrow Meta. If I understand it correctly, a plugin with Arrow Meta can intercept at each step of the compiler. Therefore I should be able to change the AST before any annotation processing takes places by other third party libraries, is that correct? If so, is there any example on how to achieve this? I tried something like the following, currently with no success:
    val Meta.injectProperty: CliPlugin
        get() = "Inject new property" {
            meta(
                classBody(this, { true }, fun ClassBody.(c: KtClassBody): Transform<KtClassBody> {
                    if (c.name?.contains("User") == true) {
    
                        return Transform.replace(
                            replacing = c,
                            newDeclaration = """
                                | 
                                | @ColumnInfo(name = "name")
                                | var name: String = ""
                                |
                                | @ColumnInfo(name = "nameabc")
                                | var nameABC: String = ""
                                | }""".classBody
                        )
                    }
                    else {
                        return Transform.empty
                    }
                })
            )
        }
    r
    • 2
    • 4
  • j

    Jörg Winter

    12/22/2021, 6:07 PM
    Hi, is there anything available for IntelliJ, so that Arrow Optics elements (the generated lenses for example) are not marked as (red) errors ? (this is from the 'backend-arrow-example')
    s
    l
    • 3
    • 4
  • p

    Peter

    12/23/2021, 1:10 AM
    having a little trouble getting the ksp plugin for optics: https://arrow-kt.io/docs/optics/#Gradle-kotlin
    a
    • 2
    • 3
  • m

    Marius Kotsbak

    12/23/2021, 11:58 AM
    Is Arrow having something like zip function for nullable Kotlin variables? Solving this problem: https://stackoverflow.com/questions/35513636/multiple-variable-let-in-kotlin
    t
    y
    • 3
    • 6
  • o

    Oliver Eisenbarth

    12/27/2021, 7:22 PM
    • Hi! I just took a look at the tests for the proof plugin, but I didn't understand, what it is about. Could somebody tell me, what usecases there are for Proofs / what it does? Thx.
    r
    • 2
    • 2
  • q

    Quantum64

    12/27/2021, 8:27 PM
    Hello everyone. We are thinking about starting to incorporate the Arrow Optics DSL into a substantial (100k+ loc) project. We have two questions: 1. Is there a plan or roadmap for supporting the K2/FIR compiler for Optics DSL? We are concerned about becoming heavily invested in the generated optics but unable to update our compiler or language version due to lack of support. 2. Could a tool be built for generating Kotlin source code for Optics DSL properties in case we need to "back out" of using the compiler plugin (similar to https://projectlombok.org/features/delombok)? This would give us peace of mind in the case that we cannot continue to use the plugin, we would not need to invest a huge effort in manually writing the optics. This in particular would make it much easier for me to sell Optics DSL to the team. 😉 Thanks for working on this great project!
    r
    • 2
    • 2
  • l

    Lukasz Kalnik

    12/28/2021, 10:21 PM
    Can I use Kotest Arrow assertions while working on Arrow itself? I'm working on a PR for the
    arrow-core-retrofit
    module. I added a dependency on
    io.kotest.extensions:kotest-assertions-arrow
    but when I try to use the
    shouldBeRight
    assertion the test doesn't compile with the error "Cannot access class 'arrow.core.Either'. Check your module classpath for missing or conflicting dependencies"
    s
    i
    • 3
    • 24
  • q

    Quantum64

    12/30/2021, 8:02 PM
    I have a question about the generated Optional optics for nullable fields. The laws for affine traversals state that "If you get nothing when extracting a value, then whatever you put in, the operation is no-op" (http://oleg.fi/gists/posts/2017-04-18-glassery.html#laws:affine-traversal). The generated code that I see for a nullable field is setting the value without checking if a value is present. Here's an example:
    inline val TestOptics.Companion.nullable: arrow.optics.Optional<TestOptics, Int> inline get()= arrow.optics.Optional(
      getOrModify = { testOptics: TestOptics -> testOptics.`nullable`?.right() ?: testOptics.left() },
      set = { testOptics: TestOptics, value: Int -> testOptics.copy(`nullable` = value) }
    )
    Is the arrow Optional optic not equivalent to an affine traversal? If not, what is it equivalent to?
    n
    s
    • 3
    • 5
  • g

    Gavin Ray

    01/01/2022, 7:23 PM
    I see in
    arrow-meta
    there is a plugin which provides a macro called
    @Given()
    From the tests, it seems to be roughly identical to Scala 3's
    given
    +
    using
    where you say "This function requires some type
    Foo
    to have a value provided in the context/scope" Is this sort of like an implementation of the Multiple Receivers proposal as a compiler plugin? https://github.com/arrow-kt/arrow-meta/blob/8f9e80bfbbcb12c16f025bc5ca7d69cbeeec08[…]gin/src/test/kotlin/arrow/meta/plugins/typeclasses/GivenTest.kt
    j
    • 2
    • 2
  • g

    Gavin Ray

    01/03/2022, 7:09 PM
    Quick theoretical question: I have code which is parsing a GraphQL query into its AST, and then transforming that into a more specific "AST" (really just nested Kotlin dataclasses) Would this be something that
    lenses
    would be beneficial to for performance purposes, rather than creating an entire new AST object?
    s
    • 2
    • 2
  • s

    simon.vergauwen

    01/04/2022, 1:38 PM
    If any Gradle wizard has any idea about the following issue that’d be great 🙏 https://kotlinlang.slack.com/archives/C8UK6RTHU/p1641303439037300.
    b
    p
    • 3
    • 5
  • h

    Hareendran

    01/05/2022, 2:09 AM
    I’m just starting to work with arrow I use
    <kotlin.version>1.5.31</kotlin.version>
    but when I use
    <dependency>
                <groupId>io.arrow-kt</groupId>
                <artifactId>arrow-core</artifactId>
                <version>0.12.1</version>
            </dependency>
    
            <dependency>
                <groupId>io.arrow-kt</groupId>
                <artifactId>arrow-fx</artifactId>
                <version>0.12.1</version>
            </dependency>
    it leads to a warning that there are multiple koltin jars
    s
    • 2
    • 18
  • k

    Kaushalya

    01/05/2022, 7:33 AM
    Anyone using Arrow on Android? How you use it? Please share your experience
    t
    j
    +2
    • 5
    • 21
  • j

    julian

    01/07/2022, 12:32 AM
    Why does
    Either.bifoldMap
    take a
    Monoid
    argument, when the monoid basically does no work, since
    bifoldMap
    always combines the mapped values of the
    Either
    with
    empty
    , where the result of that combination is know ahead of time to always be the same as the mapped values. In other words, why jump through the hoop of combining a value with
    empty
    , when we know the result will always be the same original value?
    s
    r
    • 3
    • 10
  • j

    julian

    01/08/2022, 5:33 PM
    Looks like https://arrow-kt.io/docs/meta/ is raising a
    404
    . In case it hasn't already been reported...
    ➕ 1
    r
    i
    • 3
    • 8
  • p

    pakoito

    01/09/2022, 11:37 AM
    IIRC
    either
    blocks with a for/while and a bind should do it
    j
    • 2
    • 1
  • l

    leomayleomay

    01/10/2022, 7:34 AM
    I could see arrow-fx is using Kotlin
    suspend
    to replace IO tell apart codes w/o side effects, while thing I could not get is how to enforce it for dependencies? the impure code from dependency will not have
    suspend
    in the function definition, which means we could always use them in a “safe” environment?
    p
    • 2
    • 2
  • h

    Hareendran

    01/10/2022, 2:59 PM
    does anyone know what I’m missing with this compilation error?
    Kotlin: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
        class arrow.core.Either, unresolved supertypes: arrow.Kind
    p
    • 2
    • 1
  • h

    Hareendran

    01/10/2022, 2:59 PM
    I have function that returns an
    Either
    fun getConfigVersion(configId: ConfigId, versionId: ConfigVersionId): Either<DomainError, PIConfigVersion> {
            val configVersion = configVersionRepository.findByPiConfigModel_ProfileIdAndVersion(configId.id, versionId.id)
            return configVersion?.right() ?: NoVersionsFound("No ConfigVersion found for Config ${configId.id} and version ${versionId.id}").left()
        }
    t
    r
    • 3
    • 18
  • z

    Zahara Vidumshikova

    01/11/2022, 2:40 PM
    There are some strange things in readme from GitHub: 1. In Λrrow Core + Λrrow Optics we add Λrrow Meta 2. There are ways to add Core + something one. But if I want to use Optics and Fx at the same time?
    r
    • 2
    • 2
  • i

    itbhp

    01/11/2022, 5:26 PM
    Hi people have you ever encountered this error
    kotlin.NoWhenBranchMatchedException: null
    	at arrow.core.computations.EitherEffect$DefaultImpls.bind(either.kt:20) ~[arrow-core-jvm-1.0.1.jar:?]
    I am using the either monad comprehension block and the bind extension function but maybe I am missing something. I am using arrow version 1.0.1 Basically I have few interface with suspended methods, and one interface exposing a method not suspended (and using jooq in the implementation to handle transactions)
    interface Repository {
      suspend fun getBy(userId: UserId): Either<Error, List<DomainObject>>
      suspend fun update(obj: DomainObject) : Either<ErrorResult, Unit>
    }
    class TransactionMgmt(private val dslContext: DSLContext) {
    
        fun <T> transaction(
            block: () -> Either<Error, T>
        ): Either<ErrorResult, T> ...
    interface Observer {
    
        suspend fun onExpired(obj: DomainObject): Either<ErrorResult, Unit>
    }
    class ExpireUseCase(
        private val repository: Repository,
        private val transactionMgmt: TransactionMgmt,
        private val observer: Observer
    ) : UseCase<Request, Response> {
        override suspend fun execute(request: Request): Either<Error, Response> =
            repository.getBy(request.userId)
                .flatMap { obj ->
                    updateAndNotify(obj)
                }
    
        private suspend fun updateAndNotify(objs: List<DomainObject>): Either<Error, Response> {
            return objs.fold(initial) { acc, obj ->
                transactionMgmt.transaction {
                    runBlocking {
                        expire(obj, acc)
                    }
                }
            }
        }
    
        private suspend fun expire(
            obj: DomainObject,
            acc: Either<Error, Response>
        ): Either<Error, Response> = either {
            val expiredObj = obj.copy(status = EXPIRED)
            repository.update(expiredObj).bind()
            observer.onExpired(expiredObj).bind()
            Response(acc.bind().count + 1)
        }
    
        private val initial: Either<Error, Response> = Response(0).right()
    }
    Basically I am getting that error in the method
    private suspend fun expire(
            obj: DomainObject,
            acc: Either<Error, Response>
        ): Either<Error, Response> = either {
            val expiredObj = obj.copy(status = EXPIRED)
            repository.update(expiredObj).bind()
            observer.onExpired(expiredObj).bind()
            Response(acc.bind().count + 1)
        }
    Sorry for the very long post, and maybe I am missing something really stupid but I cannot see it. (this is a similar version of the actual code I am using, I cannot post the original one)
    r
    • 2
    • 7
  • p

    Peter

    01/11/2022, 10:57 PM
    anyone know how to construct a gradle version range or selectionrule to select the latest patch version but exclude the alpha/beta/rc versions, currently
    1.0.+
    matches
    1.0.2-alpha.25
    😬
    s
    • 2
    • 3
Powered by Linen
Title
p

Peter

01/11/2022, 10:57 PM
anyone know how to construct a gradle version range or selectionrule to select the latest patch version but exclude the alpha/beta/rc versions, currently
1.0.+
matches
1.0.2-alpha.25
😬
anything better than?
configurations.all {
    resolutionStrategy {
        componentSelection {
            all {
                if (candidate.version.contains("alpha"))
                    reject("no alpha versions for $candidate")
            }
        }
    }
}
s

simon.vergauwen

01/12/2022, 8:49 AM
Ouch… It should be relatively safe to consume post
1.x.x
, but adding such resolution strategy is probably best option. You might also want to exclude
beta
and
rc
. Although
rc
would be great if people in the wild test them as a sort of community build to report issues or breaking changes 😄
If anything breaks in the alpha, than that should be an issue and we should fix it before release since we don’t want any breakage across 1.x.x versions.
View count: 9