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

    Marcin Gryszko

    06/25/2019, 5:33 AM
    Looking at the fx class hierarchy, I saw that there are two
    Fx
    interfaces: one declared in
    arrow.effects.typeclasses.suspended.concurrent
    package (with
    IOFx
    implementation, another one in
    arrow.effects.typeclasses.suspended.monad
    (for the rest of monad implementations). Is there a reason that they are separated?
    i
    r
    • 3
    • 8
  • b

    Bob Glamm

    06/26/2019, 8:26 PM
    but I'm struggling to come up with a real-life example for how to swap out instances of
    <F>
    in something like the following:
    interface S3Ops<F>: MonadDefer<F> {
    
        val s3: AmazonS3
    
        fun getS3Info(bucket: String, key: String): Kind<F, S3Object> {
    
            val waiterRequest = GetObjectMetadataRequest(bucket, key)
    
            return catch { s3.waiters().objectExists().run(WaiterParameters(waiterRequest)) }
                    .flatMap {
                        val objectRequest = GetObjectRequest(bucket, key)
                        catch { s3.getObject(objectRequest) }
                    }.flatMap {
                        if (it == null) {
                            raiseError(RuntimeException("No object retrieved from S3"))
                        } else {
                            just(it)
                        }
                    }
        }
    p
    • 2
    • 35
  • i

    Imran/Malic

    06/26/2019, 9:29 PM
    whenever I click on Download sources. It only tells me after the download, that it did not found the sources
    r
    • 2
    • 1
  • b

    Bob Glamm

    06/28/2019, 1:56 PM
    only a type error in IJ, running the actual compiler works just fine
    k
    g
    • 3
    • 4
  • d

    Derek Berner

    06/28/2019, 2:37 PM
    Is there currently any advice on building and consuming programs using the
    Free
    monad? Or should we be preferring
    IO
    for that?
    r
    • 2
    • 7
  • d

    Derek Berner

    06/28/2019, 2:47 PM
    (It also turns out I accidentally implemented the
    Free
    monad in Elm one time because their `Cmd`s were frustratingly not monadic...)
    r
    • 2
    • 1
  • a

    AdrianRaFo

    07/01/2019, 9:23 PM
    Do we have
    flatTap
    ?
    s
    p
    • 3
    • 6
  • p

    pakoito

    07/02/2019, 9:19 PM
    based off the Map implementation I’d suspect
    • 1
    • 2
  • h

    HieiJ

    07/04/2019, 8:23 PM
    Also, do you have some documentation about how Ref works?
    s
    • 2
    • 8
  • h

    HieiJ

    07/05/2019, 11:24 AM
    I've made a little post just to create some context... https://www.msec.it/blog/self-contained-example-of-testing-with-modules-and-arrow-fx/ I'm going to open a PR for this hopefully today
    s
    s
    • 3
    • 5
  • t

    Tim Fennis

    07/09/2019, 8:07 AM
    Damn man, when you guys have discussions like this I feel so dumb
    ☝️ 3
    😔 1
    p
    r
    b
    • 4
    • 33
  • n

    nicopasso

    07/09/2019, 9:06 AM
    Hey everyone, I’m using (well I’m trying to use 🙂 )
    bindingCatch
    to compose a sequence of actions (API call, db call etc). What’s the best way to test it and to assure the actions are executed?
    r
    i
    • 3
    • 13
  • t

    than_

    07/09/2019, 10:25 AM
    hi, there seems to be some changes in library contents in 0.9.1-SNAPSHOT. now i can't find Getter although I have io.arrow-kt:arrow-optics dependency. where do I find optics now? 😮
    s
    • 2
    • 4
  • t

    than_

    07/10/2019, 10:20 AM
    opened issue on github. thanks for support 🙂
    s
    • 2
    • 2
  • k

    kioba

    07/15/2019, 3:41 PM
    will there be an Arrow talk this year at KotlinConf?
    • 1
    • 1
  • j

    Jorge Castillo

    07/15/2019, 3:48 PM
    There might be something 🙂 let’s wait for the official announcements by JetBrains
    7️⃣ 1
    8️⃣ 1
    s
    r
    k
    • 4
    • 10
  • s

    simon.vergauwen

    07/15/2019, 4:08 PM
    You can group those dependencies to have the same effect.
    data class UseCaseContext(val repo: Repo, val db: Db)
    , now your use cases logic is coupled to
    UseCaseContext
    and you can deal with your dependencies further as you normally would. Interface segregation etc
    i
    r
    • 3
    • 6
  • b

    Bob Glamm

    07/16/2019, 3:23 AM
    Hopefully @raulraja will correct me where I'm wrong above
    r
    • 2
    • 1
  • b

    Bob Glamm

    07/16/2019, 3:32 AM
    Also, if I understand it correctly, higher kinds are just type constructors. But don't ask me how
    Either l r :: * -> * -> *
    is implemented via
    Kind<F, A>
    in Arrow
    s
    • 2
    • 3
  • s

    simon.vergauwen

    07/17/2019, 2:00 PM
    You can go from
    Flux<A>
    to
    suspend () -> List<A>
    or
    Mono<A>
    to
    suspend () -> A?
    b
    • 2
    • 4
  • c

    carbaj0

    07/17/2019, 2:20 PM
    because not exist an instance like this
    object : FxSyntax<ForIO> by IO.fx() { }
    s
    • 2
    • 1
  • s

    simon.vergauwen

    07/17/2019, 2:38 PM
    If you have any additional questions to the one I answered in the gist I’d love to help you further solve your problem.
    t
    • 2
    • 4
  • r

    Ryan Benasutti

    07/17/2019, 2:39 PM
    Why is there no
    SetK.applicative()
    similar to
    ListK.applicative()
    ?
    i
    r
    • 3
    • 9
  • s

    sean

    07/17/2019, 9:04 PM
    Are there any documents for working with
    fx
    ,
    Either
    and
    coroutines
    ? I've been going over the documents and feel like I'm just missing something. I see effect but it looks like it's under the IO data type.
    i
    p
    • 3
    • 20
  • h

    HieiJ

    07/18/2019, 6:39 AM
    Hi all, I've written a little blog post about effect polymorphism with fx: https://www.msec.it/blog/effect-polymorphism-with-arrow-fx/ Since I'm an FP beginner, just experimenting, do you have any comment/correction about this?
    p
    s
    r
    • 4
    • 24
  • d

    dr.dreigh

    07/18/2019, 10:53 AM
    Did I imagine it or did I see that there is a http lib using Arrow?
    k
    • 2
    • 2
  • b

    Bob Glamm

    07/18/2019, 12:30 PM
    How do I compose two coroutine libraries together? E.g., trying to bridge
    ktor
    and Arrow:
    val q: (ApplicationCall) -> Kind<ForIO, Unit> = { c -> IO.fx().fx { c.respondText("Foo", ContentType.Text.Html) } }
    c.respondText
    is a suspending function not in
    IO
    and
    @RestrictsSuspension
    on
    IO
    prevents the composition from occurring that way
    s
    • 2
    • 3
  • i

    Imran/Malic

    07/18/2019, 4:23 PM
    Why can I get from every Comonad an Monad, but not the other way around?
    s
    r
    m
    • 4
    • 11
  • d

    Derek Berner

    07/19/2019, 3:45 PM
    I need to write a "decorator" function that takes in any function with arbitrary args (A,B,C,D,...) -> Z and returns a function of the same type that performs some decoration logic. Does arrow provide capabilities to do this?
    s
    b
    r
    • 4
    • 15
  • s

    simon.vergauwen

    07/19/2019, 4:01 PM
    Oh okay, you want
    leftFlatMap
    but that currently doesn’t exist in Arrow.
    p
    r
    • 3
    • 24
Powered by Linen
Title
s

simon.vergauwen

07/19/2019, 4:01 PM
Oh okay, you want
leftFlatMap
but that currently doesn’t exist in Arrow.
p

pakoito

07/19/2019, 5:25 PM
handleErrorWith
r

Robert Menke

07/19/2019, 6:00 PM
If it’s still ok to add
flatMapLeft
I did create a branch with the functionality + test. I get an error pushing my branch up to origin because of permissions. No big deal if you’d prefer not to add extra code to maintain @simon.vergauwen @pakoito. Up to you guys.
p

pakoito

07/19/2019, 6:00 PM
I';d rather not, we aligned the names not so long ago
and we moved from mapLeft to handleError for example
s

simon.vergauwen

07/19/2019, 6:01 PM
But this is different from
handleErrorWith
It doesn’t fix
L
but rather leaves it generic.
It’s an operator of the bifunctor hierarchy, right?
r

Robert Menke

07/19/2019, 6:04 PM
Cool,
handleErrorWith
does work perfectly for my use case so I can stick with that. Thanks for pointing me in the right direction!
p

pakoito

07/19/2019, 6:04 PM
flatMapLeft
is a specialized
handleErrorWith
or just a plain alias
s

simon.vergauwen

07/19/2019, 6:05 PM
It’s the other way around
p

pakoito

07/19/2019, 6:05 PM
because you can return handleErrorWith { Either.Left("") }
I thought we kept the handleError naming so it was consistent across datatypes
s

simon.vergauwen

07/19/2019, 6:06 PM
fun <A, B, C> Either<A, B>.leftFlatmap(f: (A) -> Either<C, B>): Either<C, B> = when(this) {
  is Either.Left -> f(this.a)
  is Either.Right -> this
}

fun <A, B> Either<A, B>.handleErrorWith(f: (A) -> Either<A, B>): Either<A, B> = leftFlatMap(f)
I’m not favoring one over the other. I’d include both since I expect
leftFlatMap
to come back when we complete the bifunctor hiearchy.
It’s a very handy operator for
IO<E, A>
over
handleErrorWith
Because it can to change
E
to
Nothing
, well I guess you could name it
handleErrorWith
in a bifunctor hierarchy but then it would be an alias. Here it’s not.
@Robert Menke you’re very welcome! Glad to help any time. Sorry for the confusion.
❤️ 1
r

Robert Menke

07/19/2019, 6:18 PM
So 1 other consideration is that
handleErrorWith
is not an
inline
function so it actually doesn’t work for my use case because I need to call
suspend
functions inside. I can get by with
fold
for now, just voicing my experience.
s

simon.vergauwen

07/19/2019, 6:20 PM
That is where
IO
comes in,
Either
cannot deal with the powers of
suspend
. It cannot control the async jumps, exception being thrown etc.
r

Robert Menke

07/19/2019, 6:21 PM
Gotcha 👍 so just out of curiosity (and ignorance) why inline certain functions like
flatMap
or
fold
but not something like
handleErrorWith
?
s

simon.vergauwen

07/19/2019, 6:21 PM
With
IO
you'd do
io.handleErrorWith { e -> IO.effect { suspendFunction() } }
If those functions are still inline then that will probably change soon.
r

Robert Menke

07/19/2019, 6:28 PM
Ok that makes sense! Thanks!
View count: 2