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

    Hexa

    11/17/2019, 10:20 AM
    @raulraja serious? I have recently just managed to learn how Either, Try, Option and Validated works. Are you planning to deprecate all of them?
    👌 1
    r
    p
    • 3
    • 26
  • p

    pakoito

    11/17/2019, 11:33 PM
    You can only jump threads with Async. Defer is delayed on the start and once it does it's sync and blocking. Async is delayed on the start and the result, which is the minimal requirement to support wrapping coroutines and threading.
    👍 1
    k
    • 2
    • 1
  • p

    Pagoda 5b

    11/18/2019, 9:43 AM
    but in the middle, the traverse wraps the whole flow into an effect F
    s
    • 2
    • 33
  • b

    Bruno

    11/18/2019, 2:13 PM
    hello guys first of all thanks so much for all the effort around arrow, I can feel the energy so to say! I am invited to give a presentation in austria / vienna on "functional programmng with arrow" in late january and I am bit lost with all the changes happening right now (deprecation of adts, arrow-fx, arrow-meta, ...). I can embrace that arrow tries something completely new that does not exist in other languages... which is really cool don't get me wrong. I have a hard time learning arrow myself and I noticed that the little knowledge of fp coming from elm/haskell (or having and rough idea about maybe, either, adts, which are now deprecated, folds etc.) and the little knowledge of kotlin don't really help me out in learning the idiomatic arrow way of fp that is being created right now ... Learning arrow feels more like learning a completely new language (which is fine for me!) compared to e.g. the transition from java to kotlin or learning elm after haskell. I say this because I anticipate that the people I am going to present to will also need very basic and example driven introduction to arrow ("how do I do x with arrow?"), because most of them are even new to functional programming. I try to imagine how this could be done, using my challenges right now as valuable information. So having a hard time coming up with a very concrete question I want to broadly ask: What does a idiomatic arrow program look like? Why do I raise such a question? Because I watched the very polished arrow youtube videos (thanks for the effort) but I unfortunately didn't get a feel of how I was supposed to program with them. Since I knew Option, Either, etc. from before I knew how to apply them, but using them didn't really feel like I am using the the possibilities of arrow in the intended way. So not the pieces but seeing them used together was what I was missing there. So my proposal is that if someone could pair up with me to get me started on putting such kind of examples together then I can keep going on my own doing that for other people that need some examples to get them started ... sorry for the long post! hope to hear from any of you
    j
    p
    +3
    • 6
    • 28
  • f

    Francesco megna

    11/18/2019, 9:41 PM
    I can’t find Reader and ReaderApi in arrow 0.10.3, where is it? 🤯
    j
    r
    • 3
    • 13
  • g

    Greg Hibberd

    11/18/2019, 11:09 PM
    Hi guys, I'm still trying to get my head around thinking functionally and I'm stuck with this scenario val toBeRemoved = mapOf("id" to 2) val testList = listOf(Some("id" to 1), None, Some("id" to 3), Some("id" to 1)) //TODO val expectedOutcome = listOf(None, Some("id" to 2), Some("id" to 1)) Can be done with mutability like so val toBeRemovedMutable = toBeRemoved.toMutableMap() val actual = testList.map { item -> val id = item.first var newAmount = item.second for ((key, value) in toBeRemovedMutable) { if (id == key && value > 0) { val remove = if (value > newAmount) newAmount else value toBeRemovedMutable[key] = value - remove newAmount -= remove if (newAmount == 0) { return@map None } } } Some(item.copy(second = newAmount)) } but I can't think of a way to do it more functionally. Any suggestions?
    j
    • 2
    • 16
  • r

    raulraja

    11/19/2019, 10:46 AM
    I will be showing @Bruno what we are doing with Arrow Meta and how it impacts the future of Arrow at 12:30 pm GMT+1 (in 45 mins). Anyone interested is welcome to join and ask questions. meet.google.com/fwc-exgg-yrh
    🙌 2
    👁️ 3
    t
    s
    c
    • 4
    • 4
  • t

    thanerian

    11/19/2019, 12:22 PM
    sorry to not ask it during the meetting, but how union types could interact with when expression? I asume that a fold() method will be available, but most kotlin devs are familiar with exaustive when expression, could compiler plugin support it?
    i
    r
    • 3
    • 7
  • b

    Bruno

    11/19/2019, 12:35 PM
    can anyone provide a quick example of the syntax that replaces the "! effect {...}" syntax ... and is this already in 0.10.4-SNAPSHOT ?
    r
    j
    • 3
    • 7
  • c

    Chris Kruczynski

    11/19/2019, 7:41 PM
    Hello, I was wondering how to convert
    IO
    to
    MonoK
    nicely, could anybody help?
    s
    • 2
    • 3
  • r

    raulraja

    11/20/2019, 5:23 PM
    https://twitter.com/arrow_kt/status/1197203141973831680?s=19
    ❤️ 14
    h
    m
    • 3
    • 5
  • p

    pakoito

    11/21/2019, 6:05 PM
    handleErrorWith { e -> f(e).flatMap { raiseError(e) } }
    👍 2
    m
    • 2
    • 1
  • d

    Dennis Tel

    11/22/2019, 8:00 AM
    The laws I get but not sure how I would implement it in arrow if I have an
    Boolean expression AND Boolean expression AND Boolean expression
    😅 Do I implement it on boolean expression or is it a different type/class all together?
    j
    r
    p
    • 4
    • 25
  • j

    jimn

    11/22/2019, 8:31 AM
    it is extermely difficult to learn the arrow features and refactor a codebase while figuring out alternatives to doc 404's such as https://arrow-kt.io/docs/arrow/typeclasses/semigroupal/ and for Inject.
    j
    r
    • 3
    • 5
  • h

    Hullaballoonatic

    11/23/2019, 3:42 AM
    I am not hugely familiar with arrow, and it uses a lot of names that I do not recognize. I'm wondering if arrow offers some magic that would help me with a problem I'm having: I've been writing a units of measurement library for awhile now, and my biggest disappointment is that I can't find a way to get the compiler to automatically know that a conversion between quantity types results in a specific quantity type (instead of erased type) e.g.
    val distance = 512.m
    val time = 70.s
    
    val speed = distance / time
    The compiler only recognizes
    speed
    to be of type
    Quantity<*>
    instead of
    Quantity<Velocity>
    , even though in the code this operation is specifically instantiating a quantity of velocity. Is there some kind of magic in Arrow that could ensure this without me having to hard code every compound quantity conversion? I'm almost certain at this point that this is impossible to do.
    k
    s
    +3
    • 6
    • 49
  • r

    Ryan Benasutti

    11/23/2019, 7:50 PM
    Has any thought been given to supporting kotlinx serialization? I'm not entirely sure what would be required on the arrow side, maybe just annotating some things with
    @Serializable
    ? Adding support for it from outside arrow is a massive pain because I have to go through this process: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/custom_serializers.md#about-generic-serializers. (it's actually much easier to copy-paste the arrow classes I want to serialize and annotate them myself, but that's not exactly maintainable)
    r
    d
    • 3
    • 26
  • p

    pg

    11/25/2019, 10:39 AM
    Hello there. I'm just exploring whole Arrow's documentation and ... I'm so impressed, it charmed me. Do you recommend any video from conference or something about usage or explaining real life pros/cons or use cases for newcomer like me, with rxjava experience? I'd be delighted
    r
    • 2
    • 4
  • m

    Mark Fisher

    11/25/2019, 12:18 PM
    Hi all, another new comer here. I'm reading the docs, and going through Higher Kinds and Typeclasses, and trying to use some of the examples. The multiplyBy2 example I followed fine:
    val o = Option.functor().multiplyBy2(Option(1))
    assertThat(o.fix()).isEqualTo(Option(2))
    But I've just come across this in the dependency injection notes
    fun <F> Show<Kind<F, Int>>.printAllValues(fa: List<Kind<F, Int>>): Unit {
      fa.forEach { println(fa.show()) }
    }
    I'm trying to write some code to use this, but I'm having trouble finding the right form to invoke it. How would I call it with (say) a list of Option<Int> values? Thanks!
    r
    s
    • 3
    • 32
  • y

    Yeray Cabello

    11/26/2019, 9:19 AM
    Hello, I got a funny one today. I had an IO with a list of items inside, and I needed to apply an IO operation to each element in the list. The issue is solved in two ways, but I'm baffled as why the second-to-last and last options are different. I'm evidently missing something and I would LOVE to get it out of my head.
    Untitled.kt
    s
    a
    • 3
    • 9
  • m

    Mark Fisher

    11/26/2019, 11:46 AM
    A question about
    unsafeRunAsync
    . I have a test with 3 IO objects I've created and done an
    attempt()
    on, then I want them to run concurrently. I've tried using unsafeRunAsync expecting them to run ... asynchronously, but they run sequentially. How do I make the async IOs run concurrently?
    @Test
        fun `io module test`() {
            val ioModule = Module(IO.async())
            ioModule.run {
                val ioS1 = repository.byId(u1).fix().attempt()
                val ioS2 = repository.byId(u2).fix().attempt()
                val ioS3 = repository.byId(u3).fix().attempt()
                <http://logger.info|logger.info> { "ioS1..." }
                ioS1.unsafeRunAsync { it.fold(ioError, ioInfo) }
                <http://logger.info|logger.info> { "ioS2..." }
                ioS2.unsafeRunAsync { it.fold(ioError, ioInfo) }
                <http://logger.info|logger.info> { "ioS3..." }
                ioS3.unsafeRunAsync { it.fold(ioError, ioInfo) }
            }
        }
    My equivalent for using Observable was to use
    subscribeOn(...)
    as follows:
    repository.byId(u1).fix().observable.subscribeOn(<http://Schedulers.io|Schedulers.io>()).subscribe(idLogger, errorLogger)
                repository.byId(u2).fix().observable.subscribeOn(Schedulers.computation()).subscribe(idLogger, errorLogger)
                repository.byId(u3).fix().observable.subscribeOn(Schedulers.newThread()).subscribe(idLogger, errorLogger)
    How can I fix the
    io module test
    to run the 3 IO jobs at the same time? Thanks!
    • 1
    • 2
  • p

    pakoito

    11/26/2019, 11:53 AM
    IO.parMapN(<http://Dispatchers.IO|Dispatchers.IO>, ioS1, ioS2, ioS3) { a, b, c ->
      Either.map(a,b,c) { aa, bb, cc -> ... }
    }
    m
    • 2
    • 17
  • p

    pakoito

    11/26/2019, 11:56 AM
    note that
    <http://Dispatchers.IO|Dispatchers.IO>
    here is where the ios are started, and each can run on its own scheduler
    m
    s
    • 3
    • 14
  • a

    Attila Domokos

    11/26/2019, 5:30 PM
    I am trying to set up
    Lens
    code generation in my little learning project. The docs seem to be outdated. This is the commit that attempts it: https://github.com/adomokos/kotlin-sandbox/commit/0ac6eca63e7fffc83db113fd87ba3972807a22a2 What am I missing?
    j
    s
    r
    • 4
    • 24
  • j

    Jose Antonio Jimenez

    11/27/2019, 10:15 AM
    Any tips when migrating from Arrow 0.9.0 to 0.10? I just recently upgraded from 0.8.2 to 0.9.0
    s
    • 2
    • 1
  • k

    kioba

    11/27/2019, 11:30 AM
    I am currently working on a stream Result type
    Error<E> | Loading | Success<T>
    . I tried to implement
    applicative
    for the type. What I would like to achieve is the that the
    error
    would have a higher precedence than
    Loading
    , but the
    ap()
    implementation with
    flatmap{ .map{ ff() } }
    I can not obtain the state of the second state unless the first is success. an example that I would like to achive:
    Result.applicative().tupled(Loading, Error) 
    // current result: Loading
    Instead of the loading I am looking for the
    Error
    to be returned. is there a good way to execute it? 🤔 is that a good idea t all? 😄
    r
    j
    • 3
    • 8
  • r

    raulraja

    11/27/2019, 4:56 PM
    https://stackoverflow.com/questions/59072111/functional-programming-short-circuiting In case anyone has some time to help
    b
    j
    • 3
    • 2
  • r

    raulraja

    11/27/2019, 5:00 PM
    @simon.vergauwen is speaking today in Prague about Arrow, Fx, Meta etc in Prague. I believe is getting live streamed

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

    don’t miss it!
    🔝 9
    :arrow: 15
    👏 4
    s
    s
    • 3
    • 5
  • i

    Imran/Malic

    11/29/2019, 11:06 AM
    Is there a hack to have reified functions in Interfaces?
    s
    p
    • 3
    • 9
  • r

    Rory Armstrong

    11/29/2019, 2:32 PM
    Is there any good examples of Arrow typeclasses in use? I'm trying to wrap my head around when I'd use them compared to conventional methods but it seems to require a little more ceremony than I expect (so I expect I might be using them wrong)
    s
    p
    • 3
    • 3
  • s

    Scott Christopher

    12/03/2019, 9:56 AM
    Well, happy to lend a hand if I can whenever it picks up
    ❤️ 1
    a
    s
    • 3
    • 9
Powered by Linen
Title
s

Scott Christopher

12/03/2019, 9:56 AM
Well, happy to lend a hand if I can whenever it picks up
❤️ 1
a

aballano

12/03/2019, 7:55 PM
If you want to check the current progress, it's done in https://github.com/arrow-kt/arrow/pull/1704/files
although i need to merge master into it and adapt the changes
take into account that the approach I'm following there might not be correct tho 😅 I was doing my own reasoning but it might some structural changes still
if you have any suggestion or want to change something feel free to ping me 😊
s

Scott Christopher

12/03/2019, 10:01 PM
Great, I'll take a look.
s

simon.vergauwen

12/04/2019, 1:51 PM
Hey Scott, I’m a tad busy this week with KotlinConf. If you’re there I’d love to meet! I’m going to start working on BiFunctor IO next week. Arrow meta opens up some interesting design option for it’s implementation. There are also other very interesting contributions in Arrow Fx if you’re interested. I’d be happy to give help along the way. Some interesting other task are porting Rx concurrency operators to Reactor and building different strategies for the current purely functional tagless
Queue
impl such as
sliding
,
unbounded
, etc.
s

Scott Christopher

12/05/2019, 9:59 AM
Would gladly meet, though unfortunately I'm in the opposite end of the world at the moment. I do need to declare that I'm reasonably new to both Kotlin and Arrow, but so far have had a nice experience getting our Java devs working with it, while using it as a vehicle for teaching FP. With that caveat in mind, I'm happy to help out wherever I could be of use.
I've raised a PR to add the extra
Queue
strategies: https://github.com/arrow-kt/arrow/pull/1832
😍 2
:arrow: 2
s

simon.vergauwen

12/08/2019, 10:47 AM
Awesome first contribution!! 👏
View count: 1