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

    seetha

    01/12/2022, 7:50 PM
    HI Team, I see the latest stable release is 1.0.1 - https://github.com/arrow-kt/arrow/releases But I am not seeing this version in maven central repository - https://mvnrepository.com/artifact/io.arrow-kt/arrow-core-data Am I missing something?
    s
    • 2
    • 3
  • s

    seetha

    01/12/2022, 8:03 PM
    Also can I use kotlin 1.6.10 with 1.0.1 version of arrow?
    t
    • 2
    • 2
  • s

    seetha

    01/14/2022, 6:53 PM
    Hey Team, We are still having hard time upgrading to arrow 1.0.1. Our continuous build just fails unable to resolve the Either or any class from arrow libraries. Even though the dependencies are listed in effective pom and can see in the tree. Anybody faced this problem? Does
    kotlin-maven-plugin
    needs any modifications or configurations here?
    💯 1
    p
    r
    • 3
    • 4
  • n

    Norbi

    01/15/2022, 9:17 AM
    I'd like to integrate arrow-optics in a multiplatform project (and this is my first try to use the arrow-optics code generator). The files I modified: build.gradle.kts
    plugins {
        ...
        id("com.google.devtools.ksp") version "1.6.10-1.0.2"
    }
    
    kotlin {
        sourceSets {
            val commonMain by getting {
                dependencies {
                    ...
                    api("io.arrow-kt:arrow-optics:1.0.1")
                }
            ...
        }
    }
    
    dependencies {
        ksp("io.arrow-kt:arrow-optics-ksp-plugin:1.0.2-alpha.28")
    }
    Example.kt
    ...
    @optics
    data class Example(val p: String) {
        companion object
    }
    But no files are generated, the
    build\generated\xxxMain
    folders are created but remain empty. During the build process the corresponding tasks are executed (and I see a warning):
    ...
    The 'ksp' configuration is deprecated in Kotlin Multiplatform projects. Please use target-specific configurations like 'kspJvm' instead.
    ...
    Task ... kspKotlinJs UP-TO-DATE
    ...
    Task ... kspKotlinMetadata UP-TO-DATE
    ...
    Task ... kspKotlinJvm UP-TO-DATE
    ...
    Do you have any idea what piece is missing? Thanks.
    s
    a
    i
    • 4
    • 23
  • j

    João Gabriel Zó

    01/16/2022, 5:36 PM
    Hello, I'm pretty new to Kotlin but wanted to start it out implementing some things with Arrow since I got a little background in FP. Is there a structured path I could follow to learn it?
    e
    • 2
    • 1
  • p

    Philipp Mayer

    01/17/2022, 5:25 PM
    Hi! Given I have 2
    Either
    of type
    <List<Error>, Success>>
    , how could I collect both of their lefts (if both are left). My setup looks like this:
    import arrow.core.Either
    
    data class Error(val message: String)
    data class Success(val data: Int)
    data class SuccessSum(val success1: Success?, val success2: Success?)
    
    fun myFunction(): Either<List<Error>, SuccessSum> {
        val responseA = someNetworkCall()
        val responseB = someNetworkCall()
    
        return TODO()
    }
    
    
    fun someNetworkCall(aGivenParameter: Int = 1): Either<List<Error>, Success> {
        TODO()
    }
    and I have the following possibilities regarding my return type: it can either be: • a list of errors originating from the first response • a list of errors originating from the second response • a list of errors originating from both responses •
    SuccessSum
    , my happy path Is there any way to check if both eithers are null and if they are, merge their left values together into one list? My happy path would then look like that:
    fun myFunction(): Either<List<Error>, SuccessSum> {
        val responseA = someNetworkCall()
        val responseB = someNetworkCall()
    
        /* Guard Clause checking for lefts here */
    
        return SuccessSum(
            success1 = responseA.orNull(),
            success2 = responseB.orNull()
        )
    }
    That’s at least my initial idea. I guess
    Validated
    could be a better option but I didn’t look into it yet. Thanks in advance! 🙂
    r
    • 2
    • 11
  • l

    Luke

    01/21/2022, 8:33 PM
    In optics, is there a way to focus on a
    Either
    only if it is a
    Left
    ? I have a state that I want to modify its
    Either
    variable, something like:
    data class State(val either: Either<Error, Something>)
    And I want something like this:
    State.either./*focusIfLeft()*/.modify(state) { left: Left<Error> -> Something().right() }
    Is there a way to do that already or a need to define my own extension?
    t
    • 2
    • 2
  • m

    Milse113

    01/27/2022, 6:08 PM
    Is it still impossible to use Arrow Analysis to ensure that a string matches a regex expression at compiletime?
    r
    • 2
    • 1
  • t

    Tower Guidev2

    01/28/2022, 11:37 AM
    hi, i am attempting to convince my android development colleagues to embrace arrow as it has now reached v1.0.0 one really great selling point is the use of optics. sadly i cannot seem to find instructions on how to configure my gradle build file to allow my build to complete successfully is there a sample android project or documentation that explains how to correctly configure and android gradle build file(s)?
    s
    j
    d
    • 4
    • 18
  • b

    Bart Kleijngeld

    01/29/2022, 1:12 PM
    Hi everyone, I am new to Kotlin (and Arrow), and have an interest to do a project adhering to the FP paradigm. I was wondering if you guys could give pointers on how to get started. Especially: there's a lot to learn about Kotlin itself, although not everything will be relevant for FP. What Kotlin basics would you say I should get down before moving to the use of Arrow? Thanks!
    p
    u
    • 3
    • 15
  • j

    jeff

    01/29/2022, 10:08 PM
    The @optics ksp codegen (using
    "io.arrow-kt:arrow-optics-ksp-plugin:1.0.2-alpha.42"
    ) seems to have a bug: if I put @optics on a data class with 3 or fewer fields it generates code with
    first
    ,
    second
    ,
    third
    which is great because arrow.core.Tuple3 has those fields.
    But once I hit 4 fields it starts generating code with
    a
    ,
    b
    ,
    c
    ,
    d
    which fails because arrow..core.Tuple4 does not have those fields (it has
    first
    through
    fourth
    ) -- is this a known issue?
    Solved
    • 1
    • 2
  • t

    Tower Guidev2

    01/31/2022, 8:29 AM
    Hi I would like to know if anyone has managed to get arrow optics to work (e.g. generate code) in an Android studio project? i have been trying to achieve this for the last 4 days and failed.
    a
    • 2
    • 13
  • s

    Srki Rakic

    02/01/2022, 12:44 AM
    Hi 👋. I'm trying to use
    Validated
    instead
    require
    for validation when constructing an object.
    class Probability private constructor(val value: Double) {
      companion object {
        fun create(value: Double) =
          if (value > 0.00 && value < 1.00) Probability(value).valid()
          else ValidationError.ProbabilityOutOfBounds("Probability must be between 0.00 and 1.00").invalid()
      }
    }
    I'm struggling to find the best way to structure it in a given context. Typical use case for `Probability`:
    val fsmIdentifiers =
      listOf(
        FsmIdentifier(
          key = "first",
          mProbability = Probability(0.95),
          uProbability = Probability(0.1),
          compare = ::jaroWinklerDistance
        ),
        FsmIdentifier(
          key = "last",
          mProbability = Probability(0.99),
          uProbability = Probability(0.01),
          compare = ::jaroWinklerDistance
        ),
        FsmIdentifier(
          key = "middle",
          mProbability = Probability(0.90),
          uProbability = Probability(0.1),
          compare = ::jaroWinklerDistance
        ),
    ......
    )
    As you see, the
    Probability
    is created as part of the
    FsmIdentifier
    (and other similar identifiers). Any suggestion on how to handle the creation with
    Validated
    in this context cleanly, without making the code look overwhelmingly verbose?
    s
    • 2
    • 2
  • ł

    Łukasz Gendek

    02/01/2022, 10:50 AM
    Hello everyone. Wondering if there are any updates on this https://github.com/arrow-kt/arrow/issues/2656 ?
    s
    • 2
    • 2
  • t

    than_

    02/01/2022, 11:05 AM
    Hi, I'm trying to replace refined types with arrow analysis. Everything goes reasonably well (some NotImplementedErrors here and there). But I encountered:
    @JvmInline
    @Serializable
    value class Email(val value: String) {
        init {
            pre(value.matches(emailRegex)){ "Must be a valid email" }
        }
    
        override fun toString(): String = value
    }
    which of course won't work since
    You can only create Boolean expressions using basic arithmetic operations (addition, subtraction, …), comparisons, and simple Boolean operations (and, or, not). In particular, you cannot define a Boolean function and use it in a condition;
    Will there be possibility of regex matching in the future or should we use a runtime solution?
    r
    • 2
    • 2
  • n

    Nathan Bedell

    02/01/2022, 4:34 PM
    Hi all, quick question: Is there a function somewhere in arrow core for turning List<A?> into List<A>? (Or something similar for Option)? In Haskell, I'd use sequence for this.
    s
    • 2
    • 1
  • s

    seetha

    02/02/2022, 3:12 PM
    HI Team, Is
    retry
    function available in
    Schedule
    on version
    1.0.0
    ? We are stuck at version
    1.0.0
    because of this issue and I am not finding
    retry
    s
    • 2
    • 4
  • a

    Alejandro Serrano Mena

    02/02/2022, 6:21 PM
    We’ve just released Arrow Analysis, a plug-in for the Kotlin compiler which super-charges it with pre/post-condition checking, which can catch typical errors like accessing an element in a list without checking its length twice… and all in an extensible fashion, so you can add your own checks https://twitter.com/47deg/status/1488935292652326913
    ♥️ 14
    b
    • 2
    • 1
  • m

    mikehearn

    02/02/2022, 9:20 PM
    Hi! Where can I report bugs for Arrow Analysis? Seems like a great project and I'd love to use it but it crashes on my codebase.
    a
    • 2
    • 3
  • m

    mikehearn

    02/02/2022, 9:43 PM
    I'm curious why this syntax was adopted:
    return z.post({ it > 0 }) { "greater than 0" }
    where the string is in a block, rather than a parameter. It seems less visually noisy to write as
    z.post("greater than zero") { it > 0 }
    - yeah it's different to require, but it seems to make more sense
    👀 1
    a
    s
    • 3
    • 7
  • ł

    Łukasz Gendek

    02/03/2022, 11:24 AM
    I'm curious if there are any trainings available, so one can get more familiar with arrow
    a
    • 2
    • 1
  • p

    Peter

    02/03/2022, 4:56 PM
    trying out the
    Arrow-Analysis
    … it’s early here but am i being dense with this error? 😅
    a
    • 2
    • 9
  • g

    Gavin Ray

    02/03/2022, 5:50 PM
    Dumb question: Is it possible to run
    Arrow-Analysis
    in a separate compilation task from regular? The reason I ask is because of potentially increased compile times, which I assume would add up if you're frequently re-compiling your code to test. (Maybe this is not the case though)
    a
    r
    • 3
    • 7
  • b

    Bart Kleijngeld

    02/08/2022, 10:33 AM
    I'm an FP beginner, working up my basic understanding so that I can use Arrow. Hope this is not considered off-topic, but I would like to know if what I'm doing here is a valid FP approach, or if it's my OOP experience muddying the waters.
    r
    a
    • 3
    • 28
  • a

    alightgoesout

    02/08/2022, 4:40 PM
    Is there a way to get a compile-time warning or error when an
    Either<E, A>
    is not used? In particular, this would be great in an
    either { … }
    block when calling IO functions that return
    Either<Error, Unit>
    to prevent forgetting to call
    bind()
    on the result to propagate the error.
    m
    s
    e
    • 4
    • 8
  • b

    Benoît

    02/09/2022, 1:38 PM
    https://blog.jetbrains.com/kotlin/2022/02/kotlin-1-6-20-m1-released/ Kotlin 1.6.20 now supports multiple receivers as an experimental feature. What does this mean for Arrow when it gets fully released?
    🙌🏼 1
    🙌 4
    s
    c
    • 3
    • 2
  • d

    dimsuz

    02/10/2022, 2:35 PM
    Reading Arrow Lens' docs and I'm a bit confused. Docs mention that
    set
    has type
    A -> S -> T
    , but actual
    set
    implementations seem to have it reversed:
    S -> A -> T
    . Screenshots are from: api docs Similarly main page of Arrow Optics mentions
    set: A -> S -> S
    , but then has an example of
    playerLens.set(player, health)
    . Am I reading this wrong or is this a little bug?
    s
    • 2
    • 3
  • s

    sam

    02/10/2022, 7:52 PM
    What's the best way to "flatMap" two or more validated nels ?
    w
    r
    • 3
    • 6
  • j

    julian

    02/12/2022, 4:18 PM
    What's going on with Bow? I noticed there hasn't been a release in nearly two years. Is that an indication of weak interest in FP by developers who use Swift?
    e
    k
    • 3
    • 4
  • c

    carbaj0

    02/13/2022, 5:51 AM
    Hi, i´m playing a little with the context receivers, and i have a question/problem:
    r
    s
    +2
    • 5
    • 16
Powered by Linen
Title
c

carbaj0

02/13/2022, 5:51 AM
Hi, i´m playing a little with the context receivers, and i have a question/problem:
EitherEffect<Error,*> it´s not able to match with the any concrete type (like Int, Any?, String, etc)
Having
EitherEffect<Error,A>
instead of
EitherEffect<Error,*>
would be a right solution?
r

raulraja

02/13/2022, 11:57 AM
Hi @carbaj0, once this is merged and we do the next release you would not need that additional type argument. https://github.com/arrow-kt/arrow/pull/2661
c

carbaj0

02/13/2022, 3:36 PM
🙌 , I love how Kotlin and Arrow are evolving.
s

simon.vergauwen

02/17/2022, 10:20 AM
I wrote a little blog post about using context receivers, and it's using the new stuff that is in PR 2661. https://twitter.com/vergauwen_simon/status/1494228461233315841?s=20&amp;t=uDmKwGEEB-k9lnC8-6awgQ
👍🏼 1
❤️ 17
:kotlin-intensifies: 4
👍 2
s

Satyam Agarwal

02/17/2022, 10:51 AM
Nice blog ! Tried that myself in one of my production application, just to see how it will look. Its awesome. But limitation that we cant pass multiple parameters in with makes the start of program nasty. Also, because context receiver is available on function level, it brings repetition to all the functions using it, which basically is another way of writing a function passing the dependencies as a parameters. It would have been nice if context receiver is available on interfaces, then we could have very nice bounded contexts. Tried setting context receiver on interface, it compiles but it doesn’t run 😄
s

simon.vergauwen

02/17/2022, 11:54 AM
But limitation that we cant pass multiple parameters in with makes the start of program nasty.
This is planned afaik, but it's not been implemented in the current preview.
it brings repetition to all the functions using it
There is some repetition, yes, but I don't see this as a bad thing perse. You only need to add the receivers the function actually uses, so it's similar to effect handlers or final tagless in Haskell/Scala.
👍 2
t

Tower Guidev2

02/18/2022, 8:42 AM
Hi @simon.vergauwen I tried following your blog and guide on how to install the experimental version of kotlin to check out content recievers however i do not know how (and cannot find a solution) to getting past this ide issue
r

raulraja

02/18/2022, 9:55 AM
hi @Tower Guidev2, I believe you have to add the compiler option in gradle freeCompilerArgs for
-Xcontext-receivers
and also the same in the IDE Kotlin settings, for some reason in my case the IDE its not picking the setting from Gradle.
t

Tower Guidev2

02/18/2022, 10:50 AM
thanks, i have added that and i can now build cleanly however the red error is still shown on ide, its very odd... i think i will "give up" and wait for this feature to become available in the stable release 😄
s

simon.vergauwen

02/20/2022, 9:45 AM
@Tower Guidev2 did you update the Kotlin plugin to the EAP version? You need to have 1.6.20-EAP Kotlin plugin in IDEA, but it only works in IDEA
2021.3.2
.
t

Tower Guidev2

02/21/2022, 8:23 AM
Hi I have this version of IDEA
IntelliJ IDEA 2021.3.2 (Community Edition)
Build #IC-213.6777.52, built on January 28, 2022
and Kotlin plugin version...
s

simon.vergauwen

02/21/2022, 9:26 AM
Oh, that's very strange. That setup is working for me. Then it's probably a Gradle cache issue where it isn't picking up the
-Xcontext-receivers
flag. Can you try the repo I linked in my blogpost, that is working for me with the setup you're using. https://github.com/nomisRev/context-receivers-blog
https://github.com/nomisRev/context-receivers-blog/blob/main/build.gradle.kts#L16
View count: 8