https://kotlinlang.org logo
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
  • j

    Jörg Winter

    12/21/2020, 9:14 PM
    sorry, I know this is more of a Gradle question about work-in-progress 😄... but is arrow-fx-stm (SNAPSHOT) available in some maven repository or do I have to clone and build it locally ? ..because: this seems so much more intuitive than setting up e.g. channels, events, actors etc. ! https://arrow-kt.io/docs/next/apidocs/arrow-fx-stm/arrow.fx.stm/-s-t-m/index.html
    j
    • 2
    • 10
  • m

    Mickey Donaghy

    12/23/2020, 12:26 AM
    (unrelated) if kind is going away then how are traverse/sequence/etc. implemented in the new version?
    r
    • 2
    • 17
  • j

    Jörg Winter

    12/23/2020, 10:32 AM
    I'd like to share this very good news here: https://youtrack.jetbrains.com/issue/KT-28056 https://youtrack.jetbrains.com/issue/KT-28055 ...these seem to have arrived in the latest 1.30M1 Kotlin-Release and relate to the possibility to have inline-classes with initialisation, which should be good news to all validation- and DDD-ValueObjects afficionados 😉
    🤯 6
    t
    j
    s
    • 4
    • 9
  • i

    ibcoleman

    12/27/2020, 10:28 PM
    Was wondering if anyone could recommend a forum to discuss functional approaches to specific real-world problems using kotlin & arrow? As a concrete example, I’m playing around with a little side-project, and trying to figure out how to do OAuth token refresh in a “pure” way, or at least to move the “impure” behavior to the periphery of the system. Can anyone recommend an appropriate Slack channel for discussing such “meat & potatoes” things?
    j
    • 2
    • 1
  • s

    Srki Rakic

    01/02/2021, 5:44 PM
    Which non-blocking http client do you typically use in your apps with arrow-kt?
    s
    • 2
    • 1
  • a

    Alfi

    01/03/2021, 12:17 AM
    Hello, I'm trying to learn how best to leverage Arrow core and fx. My days are typically spent working on long running servers. This normally means something like the following managing the lifecycle of the service:
    import java.lang.Thread.currentThread
    import java.lang.Thread.sleep
    import java.util.concurrent.CountDownLatch
    import kotlin.concurrent.thread
    
    fun main() {
        val mainThread = currentThread()
        val shutdown = CountDownLatch(1)
    
        Runtime.getRuntime().addShutdownHook(thread(start = false) {
            println("Shutdown triggered...")
            shutdown.countDown()
            mainThread.join()
            println("Shutdown completed!")
        })
    
        println("Starting...")
        sleep(1000) // bootstrap long running resources (e.g. DB Connection, HTTP Server, HTTP Client)
        println("Started!")
    
        shutdown.await()
    
        println("Stopping...")
        sleep(2000) // graceful shutdown (i.e. request long running resource to stop)
        println("Stopped!")
    }
    I'm wondering how the above translates to Arrow fx.
    p
    r
    • 3
    • 23
  • i

    ibcoleman

    01/04/2021, 9:28 PM
    Hi folks, sorry to ask what I’m sure is a fairly simple question, but I feel like I’m missing something fundamental here. I’m trying to implement a simple client that uses OAuth, and that will handle expected “failure” cases like, for example, refreshing expired access tokens. To cut to the point, how can the handling of the right vs Left cases in this code be streamlined further? Surely checking isRight is an anti-pattern? 🙂
    Untitled
    m
    j
    s
    • 4
    • 5
  • t

    than_

    01/05/2021, 10:12 AM
    Hi, I've noticed the
    Either::catch
    is no longer suspend function and I'm curious what is the reasoning behind that change? I thought the reason was to denote it as a side effect, since throwing is a side effect. That I presume didn't change 😄
    s
    • 2
    • 2
  • e

    earroyoron

    01/05/2021, 1:40 PM
    I’m looking for some example of arrow
    State
    I have an object (
    Customer
    ) that has his current status as a enum val , I wanna model the posible change from a state to next (as in a state machine pending->...-> review —> onaboarded) and I think using this type is the right way but can’t find a good example
    s
    o
    • 3
    • 5
  • c

    carbaj0

    01/10/2021, 10:35 AM
    the nullable case not compile 😅 :
    Exception in thread "main" java.lang.AbstractMethodError: Receiver class com.acv.composeland.ui.arrow.ArrowKt$nullable$2$1 does not define or inherit an implementation of the resolved method 'abstract java.lang.Object invoke(com.acv.composeland.ui.arrow.Either, kotlin.coroutines.Continuation)' of interface com.acv.composeland.ui.arrow.NullableEffect.
    at com.acv.composeland.ui.arrow.ArrowKt$main$composition2$1.invokeSuspend(Arrow.kt:75)
    at com.acv.composeland.ui.arrow.ArrowKt$main$composition2$1.invoke(Arrow.kt)
    at com.acv.composeland.ui.arrow.ArrowKt$nullable$$inlined$suspended$1.invokeSuspend(Effect.kt:25)
    at com.acv.composeland.ui.arrow.ArrowKt$nullable$$inlined$suspended$1.invoke(Effect.kt)
    at arrow.continuations.generic.SuspendMonadContinuation.startCoroutineUninterceptedOrReturn(SuspendingComputation.kt:88)
    at arrow.continuations.Reset.suspended(Reset.kt:27)
    at com.acv.composeland.ui.arrow.ArrowKt.nullable(Arrow.kt:88)
    at com.acv.composeland.ui.arrow.ArrowKt.main(Arrow.kt:74)
    at com.acv.composeland.ui.arrow.ArrowKt$main$2.invoke(Arrow.kt)
    at com.acv.composeland.ui.arrow.ArrowKt$main$2.invoke(Arrow.kt)
    at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$1.invokeSuspend(IntrinsicsJvm.kt:205)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
    at kotlin.coroutines.jvm.internal.RunSuspendKt.runSuspend(RunSuspend.kt:19)
    at com.acv.composeland.ui.arrow.ArrowKt.main(Arrow.kt)
    r
    • 2
    • 1
  • p

    Pratik Tandel

    01/13/2021, 1:28 AM
    Is there a
    Function1
    equivalent for suspending function / coroutines? https://arrow-kt.io/docs/0.10/apidocs/arrow-core-data/arrow.core/-function1/index.html
    s
    r
    • 3
    • 10
  • m

    Mickey Donaghy

    01/15/2021, 2:49 AM
    Monad#fx.monad
    is deprecated - apparently
    fx
    will be directly on the concrete datatypes? What does this mean for custom monadic datatypes - do I need to do anything to let me write
    fx
    blocks with my custom monad?
    s
    r
    c
    • 4
    • 24
  • o

    Oliver Eisenbarth

    01/15/2021, 6:55 PM
    Hi. Did I understand it correctly, that Arrow will get rid of the
    fix()
    calls? I just saw this and wondered, how it's going to look then. Thx and have a nice weekend.
    r
    • 2
    • 8
  • i

    ibcoleman

    01/17/2021, 10:20 PM
    Hey All, I came across a fascinating

    video▾

    with @raulraja and @simon.vergauwen on youtube: Arrow FX: Functional Domain Modeling with Kotlin. Was wondering a) is there an associated github repo? I’m having a difficult time figuring out things like i.e. required dependencies for the @Refinement annotation, etc… and b) are there more videos like this that show idiomatic Arrow being applied to real-world applications? Thanks!
    😍 3
    r
    o
    • 3
    • 3
  • k

    kluck

    01/18/2021, 4:20 PM
    Hi! I'm trying to test some IOs with delays, but get some
    IllegalStateException: This job has not completed yet
    . Here's a basic example, could you tell me what I'm doing wrong ? Thanks
    @Test
        fun test() = runBlockingTest {
            IO.effect { delay(10000) }.suspended()
        }
    p
    • 2
    • 6
  • o

    okarm

    01/19/2021, 1:36 PM
    Imagine actually not preparing a salad irl for lack of 5 grams of lettuce 😄 Taken from https://arrow-kt.io/docs/patterns/error_handling/ Hope you'll forgive the lighthearted offtopic.
    :trollface: 4
    t
    • 2
    • 1
  • m

    Marius Kotsbak

    01/20/2021, 8:40 AM
    I wonder why Ior.flatMap need to be passed a Semigroup<A> and sequence an Applicative<G>. Why isn't it just finding a "typeclass" og that type for A and G? (.semigroup() and .applicative())
    s
    r
    • 3
    • 3
  • m

    Marius Kotsbak

    01/20/2021, 1:40 PM
    What is the recommended way of doing parallell processing with Arrow now? Kotlin's async? I see parTraverse gives IO, which I though would be replaced by coroutines/suspend now?
    s
    • 2
    • 5
  • p

    Pueffl

    01/23/2021, 2:23 PM
    Hi! I'm wondering why either{} is a suspend function. I read above, that Either::catch is no longer a suspend function and would like to know if the same is true for either {...} For me that is one of the biggest flaws of Arrow as Either is a central concept and I always have to cope with suspend even when most of the code is pure.
    y
    • 2
    • 3
  • m

    Marko Novakovic

    01/24/2021, 9:02 AM
    how to use
    Either
    and
    Validated
    together?
    Either
    for fetching and
    Validated
    for validating data. I have code that parses some data and then I need to perform some check on that data to determine is it valid or not. parsing function return
    Either
    because parsing can fail and I want to validation function to return
    Validated
    based on validation logic
    s
    • 2
    • 23
  • a

    Andrei Bechet

    01/25/2021, 4:33 PM
    Hello everyone, how would you best model the
    Either<SomeFailure, Unit>
    case? Say I have to set something and don’t care about the result? We found out the hard way that having
    Unit
    in there could be a potential problem since the compiler does not oblige us to see inside. thanks
    y
    m
    • 3
    • 17
  • b

    Bob Glamm

    01/27/2021, 3:46 AM
    Is the best monad sequence syntax (as of 0.11.0) still something like:
    Option.fx {
        val (a) = Some(1)
        val (b) = Some(1 + a)
        val (c) = Some(1 + b)
        a + b + c
    }
    s
    • 2
    • 1
  • r

    raulraja

    01/27/2021, 11:22 AM
    🔈Hello everyone!, There is currently some internal discussions as to what to call the monad operator in Arrow for the 1.0 series. We plan on introducing a single version for this going forward in 0.12.0 and would love your feedback as to what style you prefer. We would love your help in helping us decide by voting in one of the following options: 1️⃣ bind
    either {
      val a = funThatReturnsEither().bind()
      val b = eitherValue.bind() 
    }
    2️⃣ invoke
    either {
      val a = funThatReturnsEither().invoke() //explicit
      val b = funThatReturnsEither()()  //implicit 
      val c = eitherValue()
    }
    3️⃣ not
    either {
      val a = !funThatReturnsEither()
      val b = !eitherValue
    }
    4️⃣ other and opinions: (reply in a thread to this message)
    1️⃣ 47
    2️⃣ 8
    3️⃣ 21
    4️⃣ 1
    t
    c
    +9
    • 12
    • 34
  • s

    Stian Brandt

    01/31/2021, 10:18 PM
    Hi! I'm following the ArrowAndroidSamples example. There we have the following code:
    fun <F> Runtime<F>.loadNews(): Kind<F, List<NewsItem>> = fx.concurrent {
        val response = !effect(context.bgDispatcher) { fetchNews() }
        continueOn(context.mainDispatcher)
    
        if (response.isSuccessful) {
            response.news().toDomain()
        } else {
            !raiseError<List<NewsItem>>(response.code().toNetworkError())
        }
    }.handleErrorWith { error -> raiseError(error.normalizeError()) }
    I get a deprecation warning on fx.concurrent:
    fx: MonadFx<F>' is deprecated. Overrides deprecated member in 'arrow.typeclasses.MonadError'. Fx will be moved to each datatype as a DSL constructor.
    What is the correct way to handle this?
    r
    • 2
    • 1
  • a

    albertosh

    02/01/2021, 9:54 AM
    Hi everyone I remember reading some time ago that Arrow wanted to implement Union types, am I right? Is there something available in 0.12 version? More info about the usecase in the thread
    y
    r
    • 3
    • 7
  • c

    Cuan

    02/01/2021, 3:10 PM
    Hi, I've never used ZIO before so maybe this is a silly question, but with
    arrow.fx.coroutines.retry
    the doc's say "The effect is executed once, and if it fails..." How does it determine failure with the effect? I've managed to achieve what I want with
    repeat
    and
    schedule.doUntil { it.isRight() }
    but it would make a little more sense to "retry a network request until is succeeds or fails 5 times" than to "repeat a network request until it succeeds or fails 5 times"
    s
    a
    • 3
    • 3
  • c

    Chris Paul

    02/01/2021, 3:18 PM
    If i have an either:
    val result: Either<VdsError, VdsData>
    and these error data types:
    sealed class VdsError {
        object NotFound: VdsError()
        object SystemError: VdsError()
    }
    is there a simple way to map on success, but also on
    NotFound
    , but break out of the mapping if
    SystemError
    ? eg
    result.map { data ->
        doSomething()
        data
    }
    basically conditionally map some failure circumstances but ignore others? I thought perhaps a conditional mapLeft would do this, but the problem is that
    mapLeft
    then returns a
    Left
    rather than a
    Right
    and then you immediately exit hope this makes sense, I'm still quite new to these sort of functional types.
    a
    h
    • 3
    • 9
  • d

    dephinera

    02/01/2021, 3:31 PM
    hello, everyone is there a shorter/cleaner way to do the following
    either1.fold(
            ifLeft = { it.left() },
            ifRight = { r1 ->
                either2.fold(
                        ifLeft = { it.left() },
                        ifRight = { r2 -> mapper(r1, r2).right() },
                )
            }
    )
    The left type of both eithers is the same. I want to call mapper() if both of eithers are
    Right
    . If one of them is
    Left
    , mapper won't be called. The result type is
    Either<SameLeftType, ReturnedTypeFromMapper>
    .
    t
    • 2
    • 10
  • i

    Ifvwm

    02/07/2021, 1:58 AM
    what's the new do-notation syntax for monads?
    r
    • 2
    • 1
  • d

    dnowak

    02/08/2021, 1:46 PM
    Hi, is there a counterpart of
    IO.handleError
    in new Fx based on
    suspend
    functions?
    s
    • 2
    • 3
Powered by Linen
Title
d

dnowak

02/08/2021, 1:46 PM
Hi, is there a counterpart of
IO.handleError
in new Fx based on
suspend
functions?
s

stojan

02/08/2021, 2:22 PM
Either.catch { mySuspendFun() }.handleErrorWith
☝️ 1
d

dnowak

02/09/2021, 11:54 PM
I’m looking for a way to add “final” error handler that would “catch” any unhandled exceptions.
Either.catch
as I understand should be used to execute side effect - similar to “legacy”
IO.effect
. Before running final
IO
I was always adding
handleError
to be sure that none of unexpected exceptions will escape.
s

stojan

02/10/2021, 7:44 AM
You could also do a try catch block. It works as expected with suspended functions
View count: 3