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

    Jorge Castillo

    03/02/2020, 11:14 AM
    Or you can better do things like:
    IO.unit
          .continueOn(<http://Uniflowdispatcher.dispatcher.io|Uniflowdispatcher.dispatcher.io>)
          .flatMap { sideEffect() }
          .unsafeRunScoped(scope) { callback ->
             // TODO
          }
    Still adding IO to the combo there is not gonna make much difference given uniflow works eagerly anyways, afaik. You’ll end up needing to unsafe run the IO to enforce the state update to happen right there, @arnaud.giuliani can confirm
    a
    • 2
    • 4
  • k

    kluck

    03/02/2020, 1:46 PM
    I can't find a unsafeRunScoped method, am I missing an arrow import? (Can't find it either on the arrow website for latest stable)
    a
    r
    • 3
    • 6
  • n

    Neil

    03/03/2020, 3:29 PM
    New to Arrow, I'm experimenting using it to replace Exceptions. Nothing async. I've a few functions that return Either<> that are called in series by a function that also returns either. If one of the called functions returns Left is there a neat way for the parent to immediately abort and return that Left?
    a
    t
    +3
    • 6
    • 96
  • j

    Jakub Pi

    03/03/2020, 8:17 PM
    New to Kotlin and Arrow, I'm trying to unwrap a
    List<Either<Throwable, C>>
    to a
    List<C>
    so that I can pass the cleaned up values to a function. I have a solution but it looks ugly, is there a more idiomatic way? Also welcome comments about approach. Underlying motivation is to start with unvalidated inputs and then only forward the parsed and validated values down to the domain layer which does not have side effects. I will log/handle errors in the next iteration.
    .fold(listOf<C>(), {acc, e -> (e.fold({null}, {it})).let {if (it!=null) acc + it else acc}})
    j
    b
    • 3
    • 4
  • g

    Gopal S Akshintala

    03/04/2020, 3:15 PM
    Hi! I have written CFP for GHC, using Arrow-kt. Request you all to please take few minutes to review and comment, in terms of technical-correctness, ambiguity, coherence. Help me improve and spread the word about Awesome Arrow. Thanks! 🙂 http://bit.ly/cfp-top
    b
    m
    +2
    • 5
    • 22
  • c

    CLOVIS

    03/06/2020, 11:25 AM
    Is there a way to get notified of major updates in Arrow? (as in, when it's going to be multiplatform, what's going on with Typeproofs, etc)? This channel is very spammy so it's inconvenient to know what's going on, I'd rather have an email notification once in a while or something like that
    r
    r
    +2
    • 5
    • 6
  • s

    Steven Sherry

    03/08/2020, 6:44 PM
    Has anyone here figured out how to get jacoco to ignore inline function coverage? I’m asking here since Arrow uses inline quite a bit (and is the cause of my uncovered inline woes) and I’m sure other people in this channel have run into it. I don’t really care if it’s “scalable”, we just have arbitrary test coverage metrics in our company and I need to massage out the lack of inline function coverage of the report that ends up getting consumed by sonarqube
    m
    j
    • 3
    • 20
  • d

    dnowak

    03/09/2020, 1:23 PM
    Hi, I have such “nice” result:
    val results: List<IO<Either<ListenerError, Unit>>> = ...
    and want to convert it to
    IO<Either<ListenerError, List<Unit>>>
    This is what I got to achieve it:
    val r = results.sequence(IO.applicative()).fix().map { l ->
        l.fix().sequence(Either.applicative()).fix().map { list ->
            list.fix()
        }
    }
    Is there any better/nicer way?
    s
    • 2
    • 2
  • n

    Nikhil

    03/10/2020, 2:07 PM
    Hi, sorry to bother you guys this question might be asked before but i recently joined the channel so wanted to ask, Is there any ongoing/already presented proposal (KEEP) for including the arrow or some of the FP concept from arrow in the language ? If not why? Are we trying to preserve the oops nature of the Kotlin ? Why can’t we add a dual paradigm to it? or Will arrow be served as a library always ?
    p
    • 2
    • 3
  • c

    Chris Kruczynski

    03/10/2020, 4:46 PM
    Hi! Sorry for rehashing this, but I wonder if a stream will keep all reactive characteristics when I convert a Mono to IO, and then IO back to Mono. I suppose it will as they are lazy-evaluated, but I want to double check
    s
    • 2
    • 2
  • g

    Gopal S Akshintala

    03/12/2020, 12:14 PM
    Hi, I have a requirement to make use of two typeclasses
    Async<F>, ApplicativeError<S, Nel<E>>
    . I achieved it as below:
    interface RepoTC<F> : Async<F> {
        fun User.isUserCityValid(): Kind<F, Boolean>
    
        fun <S> ApplicativeError<S, Nel<ValidationError>>.userCityShouldBeValid(user: User) = fx.async {
            val cityValid = user.isUserCityValid().bind()
            if (cityValid) this@userCityShouldBeValid.just(cityValid)
            else raiseError(UserCityInvalid(user.city).nel())
        }
    }
    But it just doesn’t feel right, as: - It can’t be extended if I need other typeclasses. - I see
    ApplicativeError
    in
    Async
    hierarchy. So do I need both the TCs? I tried this, but am getting compiler errors due to clashes.
    interface RepoTC2<F, S> : Async<F>, ApplicativeError<S, Nel<ValidationError>> {
        fun User.isUserCityValid(): Kind<F, Boolean>
    
        fun userCityShouldBeValid(user: User) = fx.async {
            val cityValid = user.isUserCityValid().bind()
            if (cityValid) just(cityValid)
            else raiseError(UserCityInvalid(user.city).nel())
        }
    }
    Can I achieve it just by using Async itself?
    r
    p
    • 3
    • 11
  • u

    udalov

    03/13/2020, 12:57 PM
    Hi Arrow team! I'm trying to compile arrow with Kotlin 1.4 and getting the following error from `:arrow-core-data:kaptKotlin`:
    Caused by: org.jetbrains.kotlin.kapt3.base.util.KaptBaseError: Exception while annotation processing
            at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:84)
            at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:35)
            at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45)
            ... 26 more
    Caused by: java.lang.NullPointerException: e.localizedMessage must not be null
            at arrow.common.utils.AbstractProcessor.processElementDoc(AbstractProcessor.kt:75)
            at arrow.common.utils.AbstractProcessor.processDocs(AbstractProcessor.kt:101)
            at arrow.common.utils.AbstractProcessor.process(AbstractProcessor.kt:107)
            at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
            at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
            <...>
    Have you met something similar and maybe you know how to workaround this problem?
    r
    • 2
    • 5
  • d

    dnowak

    03/13/2020, 4:33 PM
    Hi, does anyone have experience with Arrow and Spring Cloud Sleuth? We use IO a lot and we need to somehow pass the Sleuth context via IO.
    a
    • 2
    • 2
  • d

    Daniele Bartorilla

    03/13/2020, 8:59 PM
    Hi, i'm having trouble generating optics for a simple internal sealed class. For example:
    @optics
    internal sealed class X {
    
        data class Y(val foo: String): X()
    
        object Z: X()
    
        companion object
    }
    The issue is that the generated extensions are internal:
    'public' member exposes its 'internal' receiver type Companion
    . Am i doing something wrong?
    r
    • 2
    • 2
  • a

    Ahmed Ibrahim

    03/14/2020, 10:56 AM
    How can I combine two eithers into a third that's a result of a suspend function? I tried Either.applicative.map, but apparently the combine block doesn't allow a suspend function to be executed, what's the best way to tackle that?
    Either.applicative().map(sectionsResult, sectionsResult.map(this::gatherAllSaleIds)) {
                        (sections: List<SalesSectionsQuery.SalesSection>, saleIds: List<SaleId>) ->
    // This is a suspend function   remoteSalesDataSource.sales(AFFILIATE, saleIds)
                }
    a
    • 2
    • 8
  • m

    marc0der

    03/14/2020, 11:09 AM
    Hi, all. As many of you know I am in the process of translating the Scala Red Book into Kotlin (aka, the Orange Book). I am progressing well and am currently at work on Chapter 9 about writing a purely function parsing library. I have run across the first constraint in the language where I would need input from my Arrow friends! Here is the problem: I need to declare an interface that has nested type parameters (which Kotlin does not support). This is how it looks in Scala:
    trait Parsers[ParseError, Parser[+_]] {
      def run[A](p: Parser[A])(input: String): Either[ParseError, A]
      def char(c: Char): Parser[Char]
    }
    The problem of course comes when declaring the type constructor
    Parser[+_]
    , and when you subsequently try to use a
    Parser
    without the type constructor present, we get an error on the
    char
    parser declaration to the effect of "_type arguments not allowed for type parameters"_. I was hoping that I could use
    Kind
    to solve this problem but not sure how to go about it. Any help would be greatly appreciated!
    🙌 5
    🔝 3
    :arrow: 5
    a
    r
    +3
    • 6
    • 28
  • p

    pakoito

    03/15/2020, 2:17 AM
    either make something that works for Applicative so it works for both and any other implementation; or make 2 functions, one for either and the other for validated
    g
    r
    • 3
    • 14
  • b

    bmarinovic

    03/15/2020, 5:44 PM
    Just starting to learn Kotlin. I'm coming from a FP Scala background, so I'm curious what is usual technology stack that FP-side of Kotlin community uses, i.e. what backend FW, what DB library, do you use coroutines or Futures, etc?
    r
    p
    • 3
    • 14
  • p

    pakoito

    03/16/2020, 11:12 AM
    I believe we made them execute in order in the latest revision. In any case I wouldn’t trust
    mapN
    to execute in order. If order matters, then use
    flatMap
    g
    j
    r
    • 4
    • 58
  • s

    Steven Sherry

    03/17/2020, 1:37 PM
    I’m finding myself doing a bunch of validations on an unknown number of items and I end up with a
    List<ValidatedNel<E, A>>
    and I’m converting that to a
    ValidatedNel<E, List<A>>
    . Is there a more idiomatic way of doing that? The actual flow of data is more like this:
    List<A> -> List<ValidatedNel<E, B>> -> ValidatedNel<E, List<B>>
    . It works, but it feels like there is probably something more “native” to arrow that would handle this kind of flow.
    a
    s
    • 3
    • 6
  • t

    than_

    03/17/2020, 2:26 PM
    Hey, quick question. IO<A> and suspend () ->A are isomorphic does that mean that after arrow meta well be able to do for example
    val useFunc: suspend (A)->B = TODO()
    val releaseFunc: suspend (A)->Unit = TODO()
    something.bracket(
        use = useFunc,
        release = releaseFunc
    )
    ?
    a
    s
    +2
    • 5
    • 9
  • a

    Archie

    03/17/2020, 3:39 PM
    Hi, I'm learning Arrow for Android Development and I got stuck on how to integrate arrow with ktor? How exactly can I run my suspend functions? Do I just:
    suspend fun someApi(): IO<SomeObject> {
        return IO.effect {         
            ktorClient.get("<http://someendpoint.com>") 
        }
    }
    May I ask for some guidance?
    r
    • 2
    • 4
  • p

    pakoito

    03/17/2020, 4:18 PM
    https://www.pacoworks.com/2019/12/15/kotlin-coroutines-with-arrow-fx/
    a
    • 2
    • 4
  • g

    gabib

    03/18/2020, 11:09 AM
    Hi, I think I saw at some point something like @given in an example. Are we going to have KEEP-87 implemented with Arrow Meta?
    r
    c
    • 3
    • 13
  • p

    pakoito

    03/18/2020, 10:44 PM
    myEither.fold({ IO.unit }, { IO.effect { susFun() } }).bind()
    k
    • 2
    • 17
  • g

    Gopal S Akshintala

    03/19/2020, 1:09 AM
    Hi, I am looking to short-circuit (with
    Applicative
    ) + lazy call functions (with
    BIO.defer
    ), so when
    mapN
    processes from left to right, first
    raiseError
    should halt the processing and rest of the functions shouldn’t be called, @pakoito helped me come-up with this approach, but I am facing 2 problems: 1. I am using BIO, but
    raiseError
    from
    ApplicativeError
    doesn’t return a
    Kind2
    , how can I get around it? 2.
    IO.defer{..}
    has this compiler error:
    Type mismatch. Required: () → IOOf<String, ???> Found: () → Unit
    for both my extension functions
    raiseAnError()
    and
    justString()
    Please help. Thanks.
    @Test
      fun `IO ApplicativeError 2`() {
            val product =
                    IO.applicativeError<String>().mapN(
                            IO.defer { raiseSomeError() },
                            IO.defer { justString() }
                    ) {}.fix().unsafeRunSyncEither()
            
            product.fold({ assertEquals("error", it) }, {})
        }
    
        private fun <S> ApplicativeError<S, String>.raiseSomeError(): Kind2<S, String, Unit> {
            println("raising an error")
            return raiseError("error")
        }
        
        private fun <S> ApplicativeError<S, String>.justString(): Kind2<S, String, Unit> {
            println("This should not be printed")
            return just("just")
        }
    s
    • 2
    • 38
  • s

    Satyam Agarwal

    03/19/2020, 4:46 PM
    Hei. I see
    0.10.5
    release github project is all done. When its getting released 😅 I am waiting for coroutine integration so that I can make my logs nicer by attaching correlation ids to them 😄
    s
    • 2
    • 2
  • b

    bjonnh

    03/19/2020, 10:27 PM
    I'm trying to convert some old arrow code and I'm struggling with that: https://pastebin.com/DJrUavqQ
    ✔️ 1
    • 1
    • 2
  • k

    kyleg

    03/20/2020, 3:32 PM
    Supposing I’ve got a
    Ref<ForIO, MyClass>
    and a
    StateT<ForIO, MyClass, Unit>
    , what is the best way to make these two work together (using the
    StateT
    to update the value wrapped in
    Ref
    ?) I have to unpack the
    Ref
    , pass it into the
    StateT
    , and use the result to update the
    Ref
    . I’m not sure how to do that without
    myRef.update { oldState ->
      val (newState, _) = myStateT.runM(IO.monad(), oldState).unsafeRunSync()
      newState
    }
    but I know the
    unsafeRunSync
    is the stinkiest code smell there ever was.
    r
    s
    • 3
    • 18
  • k

    kartoffelsup

    03/20/2020, 6:47 PM
    Has someone used Arrow.fx with Jetpack Compose already? Is there a way to use it so that we only have one unsafeRunSync per Activity?
    k
    r
    • 3
    • 3
Powered by Linen
Title
k

kartoffelsup

03/20/2020, 6:47 PM
Has someone used Arrow.fx with Jetpack Compose already? Is there a way to use it so that we only have one unsafeRunSync per Activity?
k

kyleg

03/20/2020, 7:36 PM
That’s an interesting question. From what I’ve seen of Jetpack Compose, they have this @Model annotation and
+state {}
thing that are a step backwards from immutability. I’d be interested to see what people suggest, as Compose is something I’ve been playing around with, too.
r

raulraja

03/20/2020, 10:02 PM
We are looking into compose to provide an integration with Arrow when its design is finalised and their changes to their compiler fork make it upstream to main kotlin
🔝 1
k

kartoffelsup

03/20/2020, 10:05 PM
That's awesome!
View count: 14