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

    addamsson

    10/19/2020, 4:24 PM
    Hi there! I just talked with a Jetbrains rep and they said that KEEP-87 will be implemented using multiple receivers. @raulraja do you think this will work with Arrow? Is there any collaboration on this?
    r
    k
    d
    • 4
    • 37
  • p

    Pueffl

    10/19/2020, 6:17 PM
    Has anyone an idea how to correctly setup arrow in a plain module in Android or maybe in Android at all. I have just a simple module:
    apply(plugin: "kotlin")
    apply(plugin: "kotlin-kapt")
    
    sourceCompatibility = "8"
    targetCompatibility = "8"
    
    compileKotlin {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
    
    dependencies {
    
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin")
        implementation("io.arrow-kt:arrow-core:$versions.arrow")
        implementation("io.arrow-kt:arrow-fx:$versions.arrow")
    
        testImplementation("junit:junit:4.13")
        testImplementation("com.google.truth:truth:$versions.truth")
        testImplementation("io.mockk:mockk:$versions.mockk")
    }
    This is compilable, but when I try to run a Test, I get the following exception: e: C:\Development\Projects\test\eight\android\domain\src\test\kotlin\com\eight\domain\simple\EmailAddressTest.kt: (16, 20): Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option Adding support for Java 8 language features could solve this issue. Change Java language level and jvmTarget to 8 in all modules if using a lower level. More information...
    s
    • 2
    • 3
  • s

    Scott Christopher

    10/20/2020, 5:03 AM
    Curious to know why
    either.eager {...}
    seems to need explicit type arguments, while
    either {...}
    does not. e.g.
    fun fn(): Either<Throwable, Boolean> = TODO()
    
    suspend fun example() {
        either.eager<Throwable, Boolean> {
            val a = !fn()
            val b = !fn()
            a && b
        }
        either {
            val a = !fn()
            val b = !fn()
            a && b
        }
    }
    k
    • 2
    • 6
  • t

    tim

    10/21/2020, 12:57 PM
    Hi all, i'm getting a
    Duplicate JVM class name
    error after moving to arrow 0.11.0 and Kotlin 1.4.10 when using optics. As far as I can tell this is similar to the issue @Joram Visser raised here except in my case I'm using gradle not maven. I'm struggling to debug this, because optics are compiling correctly elsewhere in the same project, and it just seems to be one data class that is now causing this error. I tried creating a new repo and reproducing but it compiles and run fine. Any suggestions on how to approach debugging this?
    j
    r
    • 3
    • 5
  • p

    pakoito

    10/24/2020, 5:38 PM
    unwrapBody
    is what you’re after
    d
    • 2
    • 2
  • d

    dephinera

    10/24/2020, 6:55 PM
    Hello. Is there a reason to not have an
    Either.ifRight { rightValue -> ... }
    extension? Is this an antipattern?
    m
    • 2
    • 1
  • b

    Big Chungus

    10/24/2020, 7:13 PM
    Any ETA on MPP arrow release?
    r
    d
    a
    • 4
    • 11
  • p

    pakoito

    10/24/2020, 7:25 PM
    you can call
    map
    and instead of returning a value, do a side-effect that returns `Unit`inside. It’s not a good pattern but that fits every use case for
    ifRight
    d
    s
    m
    • 4
    • 30
  • p

    Petr Makagon

    10/26/2020, 2:58 AM
    What's the best way to combine errors in List<ValidatedNel<MyError, Unit>> to ValidatedNel<MyError, Unit> ?
    a
    s
    • 3
    • 9
  • s

    Srki Rakic

    10/26/2020, 10:39 AM
    Is there a way to have Schedule with exponential back off for up to n times?
    fun <A> policy() =
        Schedule.exponential<A>(100.milliseconds)
            .whileOutput { it.millis < 1000 }
            .or(Schedule.recurs(3))
    What am I doing wrong here?
    s
    • 2
    • 4
  • h

    hhariri

    10/28/2020, 3:56 PM
    So what you’re saying is that it’s pointing in the right direction? I’ll let myself out.
    🤦 3
    😂 2
    🥁 18
    😀 1
    a
    s
    y
    • 4
    • 4
  • t

    TwoClocks

    10/30/2020, 2:55 AM
    I got a noob FP question : I got a app that reads messages off the wire (different types), and builds state from that (and only that), then spits out other msgs, or does some work. So two questions come to mind: 1. Where exactly do I "keep" my state? and how to I keep it immutable? Every msg will update it (add or delete something to some data structure). Do I just
    fold
    over the stream of msgs and my state lives in the fold? How can anything external to the fold access it? 2. How do you manage the IO, it's basically almost all IO w/ a small state-machine in the middle This is a pretty typical pattern for the finical markets.
    a
    p
    j
    • 4
    • 20
  • c

    CLOVIS

    10/31/2020, 6:07 PM
    Hi! I have an application that essentially resolves around making requests to various servers (for example, I can ask to query a specific documents to multiple servers, and they might all reply, or only a few reply, or none reply). The difficult thing is that some servers might request additional user information (for example, for some files a server might need authentication, but not for others, or it might ask the user for confirmation before doing something, or it might ask the user for their age... Or anything else). The ‘questions' from servers are usually yes/no questions, but sometimes can be more involved. Currently, the application is written like this: • ‘search' requests are functions that return flows • ‘action' requests are just suspended functions • when a server requests additional information, that function suspends and asks the user, then resumes and sends the information to the server. Since this project already uses some Arrow features (
    Either
    ...), I'm wondering how I could go around to make it ‘more functional'. I see that functions that return flows are better than simple suspend functions returning a list because the side effect doesn't happen during the function execution but is ‘stored' within the type. I don't really see a way to do the same with ‘action' requests, apart from returning a Flow with a single value (or would you say that's good code?) If I understand, that's what
    IO
    was for, but since it seems like it has been replaced by
    arrow-fx-coroutines
    , I'd rather learn the ‘new version' The other problem is the user interaction: currently, the user interaction consists of a few suspend functions that are called deeply inside the program. This way, it's not really possible for the ‘client' of the application to use a different UI. Usually this would be solved with Dependency Injection, but the Arrow wiki implies Typeclasses can assume that role in a better way. Essentially, which steps would you take to change the architecture of this application so it's more functional? This particular project only runs on the JVM, if that changes anything, but I'd like to learn about techniques that work everywhere if that's possible. I've already went through and made all objects immutable, which should make the translation easier?
    j
    g
    p
    • 4
    • 4
  • c

    carbaj0

    11/01/2020, 7:16 AM
    hi, Isn't there already a helper function to transform nullable to either? Something like this:
    fun <A, B> A?.toEither(error: () -> B): Either<B, A> =
        this?.right() ?: error().left()
    s
    • 2
    • 3
  • k

    Karsten Gebbert

    11/01/2020, 9:42 AM
    Hi all! I"m trying to use
    Free
    for a small test, and I'm basically following along this example in the tests: https://github.com/arrow-kt/arrow-incubator/blob/master/arrow-free-data/src/test/kotlin/arrow/free/FreeTest.kt My questions are these: • where does
    .fix()
    "come from", i.e. which import am I missing? •
    'fx: MonadFx<FreePartialOf<ForProgram> /* = Kind<ForFree, ForProgram> */>' is deprecated. Fx will be moved to each datatype as a DSL constructor.
    <- how to deal with this?
    r
    j
    • 3
    • 6
  • c

    carbaj0

    11/01/2020, 11:10 AM
    is Stream available in 1.0.0-SNAPSHOT?, i can't found it
    a
    s
    • 3
    • 6
  • d

    Davide Bertola

    11/02/2020, 8:08 AM
    Hi, I am new to arrow. I have been using kotlin for Android development and i wanted to explore arrow. So far I am a bit confused by many overlapping apis, there seem to be multiple ways to do the same thing and it is not clear to me how things should be used. Example IO { ... } vs IO.async().async { ... }.unsafeRunSync() vs IO.async().run { fx.async { ... }.fix().attempt().unsafeWhateverRun() }
    s
    r
    +3
    • 6
    • 42
  • d

    Davide Bertola

    11/02/2020, 4:25 PM
    in a reactive-ish Android app how would I use arrow to represent the state and update views as the state changes ? (I am used to reactive programming where each view "binds" to the state with combine/subscribe)
    j
    • 2
    • 8
  • t

    TwoClocks

    11/02/2020, 8:40 PM
    does arrow-core work w/ 1.4.x of kotlin?
    k
    • 2
    • 2
  • d

    davec

    11/04/2020, 3:22 PM
    With the release of
    0.11.0
    (or
    1.1.0-SNAPSHOT
    ) is there any migration guide for what has changed (https://arrow-kt.io/docs/next/fx/ is not what I'm looking for, I am looking for a comparison of how things were done in previous releases versus
    0.11.0
    ). Along with that, are there any actual code examples for the 0.11.0 / 1.1.0-SNAPSHOT releases? Again, I don't want https://arrow-kt.io/docs/next/fx/ as there are no code samples of how to do monad comprehensions, as an example. For example, take this example from @mattmoore’s blog post https://lambda.show/blog/arrow-io-monad-comprehensions-cleaner-monadic-composition... what's the equivalent syntax of this?
    fun getAddressFromOrder(orderId: Int) = IO.fx {
        val order = !getOrder(orderId)
        val customer = !getCustomer(order.customerId)
        val address = !getAddress(customer.addressId)
        address
    }
    s
    • 2
    • 3
  • d

    davec

    11/04/2020, 3:24 PM
    In general, can anyone point me to any documents, blog posts, videos, etc. that specifically cover the new syntax changes in
    0.11.0
    (not older versions) other than the (very spare) Arrow docs?
    • 1
    • 1
  • d

    davec

    11/04/2020, 3:30 PM
    Related note: Is this page https://arrow-kt.io/docs/patterns/monad_comprehensions/ up to date with the 0.11.0 syntax? Looks like not.
    p
    • 2
    • 1
  • o

    obobo

    11/05/2020, 10:26 PM
    Hello, I have an application written using kotlinx coroutines, and as a proof of concept/learning opportunity I'm thinking of porting it to arrow-fx, but I'd like to confirm that I've got some concepts straight, I wasn't able to find answers in the docs, so apologies if this is already covered somewhere. I use launch to start up long-running 'worker' Jobs, which I sometimes need to cancel and restart. Is using
    ForkConnected
    to start up fibers the correct abstraction? I use Channels to have different Jobs communicate. Are queues used for a similar purpose as channels? Is there an equivalent to
    select
    ? In particular, I'd like have some behavior repeated periodically OR when a signal is received, whichever is first. Would I use a
    Race
    with a
    Schedule
    for that?
    s
    • 2
    • 1
  • k

    Krystian Rybarczyk

    11/06/2020, 3:08 PM
    hey guys, is there any workaround for calling a suspend function inside
    handleError
    ? I’m getting
    Suspension functions can be called only within coroutine body
    😞
    t
    • 2
    • 4
  • p

    pakoito

    11/09/2020, 11:31 AM
    weird. Try a clean build
    r
    s
    • 3
    • 16
  • j

    Johan Basson

    11/10/2020, 6:19 AM
    Good day. I have a function which returns an Either<DomainError, Id> which i need to invoke in a loop for a few times. What would be the best way to implement this loop taking into account that when a Either.Left<DomainError> is returned then the loop should stop?
    s
    t
    +3
    • 6
    • 11
  • m

    marc0der

    11/12/2020, 10:31 PM
    Hi Folks! I hope you are all keeping well in these COVID times. I'm nearing the end of my journey with the FP in Kotlin book (just put finishing touches on chapter 14 - Local Effects 🎉) but am in need of some help and advice from the Arrow masters. 😄 For those who haven't read the Scala red book, this chapter deals with a datatype called
    ST
    , short for State Token, which is a type that encapsulates local memory mutation and isolates the outside world from it.
    ST
    is also a
    Monad
    , and works very similar to the
    State
    monad. In my code samples while working with
    ST
    , I am ending up with gnarly nested
    flatMap
    and
    map
    sequences that seem so redundant and difficult to interpret for the reader. I would love to replace these nested monstrosities with neat for comprehension
    fx
    blocks, and I have been digging into the arrow source code to get some tips about how to achieve this. The problem is that adding
    fx
    binding capabilities to my own data type seems way complicated. Is there an easy way to achieve this? (or at least a guide or tutorial that instructs how to go about equipping your own data types with
    fx
    binding)? Hoping that someone can advise or shed some light on this. I really appreciate any help you can provide.
    👍 1
    j
    r
    • 3
    • 10
  • s

    stojan

    11/15/2020, 5:06 PM
    In Kotlin with suspend
    try/catch
    can safely be used to recover from exceptions. source: https://github.com/arrow-kt/arrow-fx/pull/169
    does that mean that:
    val result: Int = try {
      evalOn(BlockingI)) { mySuspendFun() }
    } catch(t: Throwable) {
      5
    }
    would work?
    p
    s
    • 3
    • 2
  • s

    Satyam Agarwal

    11/15/2020, 8:47 PM
    Hei. I am seeing few issues with
    evalOn
    , and
    coroutineContexts
    . Made 2 test files to show what is happening and what I expect. https://github.com/satyamagarwal/arrow-issues/tree/master/src/test/kotlin/com/arrow/issues Can any one help me please ? feel free to take a pull and test it out.
    r
    s
    • 3
    • 9
  • p

    Pedro Sena

    11/17/2020, 8:23 PM
    hey Guys, first message here 👋 First of all, great work on Arrow, having a good time using it. If I understood correctly Arrow 0.11 will no longer use IO and instead will simply be rely on
    suspend
    , is that correct ? We are using
    grpc-kotlin
    and it already converts everything to
    suspend
    functions and I'm wondering if now is a good time to start migrating the codebase to use 0.10 or should I wait for 0.11 and potentially not even need to use
    IO
    (if I understood it correctly ofc)
    s
    r
    • 3
    • 4
Powered by Linen
Title
p

Pedro Sena

11/17/2020, 8:23 PM
hey Guys, first message here 👋 First of all, great work on Arrow, having a good time using it. If I understood correctly Arrow 0.11 will no longer use IO and instead will simply be rely on
suspend
, is that correct ? We are using
grpc-kotlin
and it already converts everything to
suspend
functions and I'm wondering if now is a good time to start migrating the codebase to use 0.10 or should I wait for 0.11 and potentially not even need to use
IO
(if I understood it correctly ofc)
s

Scott Christopher

11/18/2020, 12:14 AM
should I wait for 0.11
Not sure if I have misunderstood, though v0.11 is the current stable release. I can't speak on behalf of the Arrow crew, though our team has decided to make full use of the suspend functionality in Arrow in v0.11 which so far is working really well. Most of what would've previously been functions returning
EitherT<ForIO, ServiceError, A>
are now simply
suspend fn(): Either<ServiceError, A>
and making heavy use of
either.fx
There was a great doc in the
arrow-fx-coroutines
repo that compared the two previously, though it looks like it has since been repurposed for other content. The previous doc can still be accessed here: https://github.com/arrow-kt/arrow-fx/blob/ad96d2e8348bc56ad20e1014f0e9059622cd259d/arrow-fx-coroutines/README.MD
r

raulraja

11/18/2020, 10:04 AM
suspend is the future, IO will be deprecated in the next release alongside kind emulation and other redundant APIs to trim down arrow before final stable release
p

Pedro Sena

11/18/2020, 11:50 AM
thank you both, I'll check that docs and keep in mind that IO will be deprecated 🙇
View count: 10