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

    phldavies

    10/25/2022, 6:40 PM
    I’m seeing something rather weird with the
    result {}
    computation (arrow 1.1.3, kotlin 1.7.20, but also occurs in 1.6.21 at least). Notably, if you switch dispatcher within the computation as follows:
    result {
        withContext(<http://Dispatchers.IO|Dispatchers.IO>) {}
        1
    }
    you end up with nested
    Success(Success(1))
    , despite the return type being correctly
    Result<Int>
    . Weirdly, using the following in it’s stead
    private suspend inline fun <A> result(crossinline f: suspend ResultEffectScope.() -> A): Result<A> =
        effect { f(ResultEffectScope(this)) }.toResult()
    Works as expected, but looks to be identical in implementation. I’ve also realised I still have no idea when best to use
    runCatching {}
    vs
    result {}
    vs
    Either.catch {}
    😳
    s
    • 2
    • 4
  • c

    CLOVIS

    10/26/2022, 1:37 PM
    What's the current stability status of Arrow Core for multiplatform projects?
    s
    • 2
    • 4
  • c

    CLOVIS

    10/31/2022, 11:33 AM
    When writing a function whose sole purpose is to check some invariant, is it best practice to declare it as:
    EffectScope<Failure>.() -> Unit
    or:
    () -> Either<Failure, Unit>
    I think the first one is clearer that "it's just validation code", what do you think? Is there any official recommendation? The first one also doesn't need the user to call
    bind
    , which they may forget since there is no proper result.
    s
    • 2
    • 1
  • d

    Davide Giuseppe Farella

    10/31/2022, 1:33 PM
    Hey, I’m trying to use arrow optics on Kotlin Multiplatform I have a Multiplatform module with JVM only, I’ve added the Ksp plugin and
    kspCommonMainMetadata(libs.arrow.optics.ksp)
    add("kspJvm", libs.arrow.optics.ksp)
    then I’ve added
    kotlin{ 
      sourceSets.all {
        kotlin.srcDir("build/generated/ksp/${this.name}/kotlin")
      }
    }
    and I see the code generated under • generated/ksp/jvm/jvmMain/kotlin • generated/ksp/metadata/commonMain/kotlin But the generated code is not resolved I believe I’m missing something in the setup (?)
    s
    • 2
    • 10
  • a

    Alejandro Serrano Mena

    11/02/2022, 12:57 PM
    hi! is anybody coming to the Kotlin Dev Day happening in Amsterdam by the end of the month? and if so, would you be interested in an “Arrow meetup” the day before (23 november)?
    t
    r
    • 3
    • 7
  • p

    Piotr Krzemiński

    11/04/2022, 10:09 AM
    Hi, just stumbled upon https://arrow-kt.io/docs/analysis/ and I’m in love with the idea 🙂 However, just gave it a test drive and it fails on some trivial cases. Please see the thread
    j
    a
    • 3
    • 9
  • d

    Davide Giuseppe Farella

    11/05/2022, 11:51 AM
    Hello, I’m experimenting with Optics, and I have something like
    playerFlow.map { player ->
      val firstNameLens = Player.name.first
      firstNameLens.set(player, "John")
    }
    If I want to modify also the last name, is there a nicer way than this?
    playerFlow.map { player ->
      val firstNameLens = Player.name.first
      val lastNameLens = Player.name.last
      val a = firstNameLens.set(player, "John")
      lastNameLens.set(a, "Doe")
    }
    w
    • 2
    • 3
  • k

    Kristian Nedrevold

    11/05/2022, 1:37 PM
    if I get Category Theory for Programmers Scala edition. How transferable will the concepts of the book be to Kotlin?
    y
    a
    • 3
    • 6
  • k

    kartoffelsup

    11/07/2022, 6:58 PM
    hi, is it possible to have a exponential jitter retry schedule that has a whileOutput and a untilInput condition? It seem that only the last one configured wins in the chain.
    val exponentialBackoff: Schedule<Throwable, Double> = Schedule.exponential(TimeUnit.SECONDS.toNanos(2L).toDouble())
    
    val retrySchedule = exponentialBackoff.jittered()
                        .whileOutput {
                           TimeUnit.NANOSECONDS.toSecods(it.toLong()) < 10.0
                        }
                        .untilInput { 
                            when (it) {
                                 is ApiException -> it.statusCode in 400 until 500
                                 ...
                                 else -> false
                            }
    the above never stops on the whileOutput condition (using this at work and don't have the code handy, it looks at least similar to above :D)
    s
    • 2
    • 28
  • s

    Slackbot

    11/08/2022, 7:40 AM
    This message was deleted.
    s
    k
    • 3
    • 4
  • k

    Kristian Nedrevold

    11/09/2022, 9:47 PM
    Will Arrow implement Typeclasses? or does that have to come from the language?
    s
    e
    • 3
    • 12
  • g

    Giorgos Makris

    11/11/2022, 10:59 AM
    Would it make sense to add support for graph data structures inside arrow? It's something I would love to help with but probably too large to handle as a personal project. Expressing graphs in a monadic way is something I haven't stumbled upon yet but it sounds exciting.
    s
    • 2
    • 3
  • j

    Jörg Winter

    11/12/2022, 10:44 AM
    fun mytimer() = Schedule.forever<String>().delay { duration ->
        Duration.Companion.seconds(5)
    }
    Hi all, What is the input argument 'duration'.. when has it a value other than 0s (in this example it is always 0s) ?
    s
    • 2
    • 5
  • y

    Youssef Shoaib [MOD]

    11/13/2022, 9:02 AM
    Is this the right channel to ask about arrow-inject? I have a question about its planned capabilities, and some conceptual hurdles that I ran into trying to implement something similar. (Also has the repo been moved to arrow-proofs?)
    j
    • 2
    • 1
  • y

    Youssef Shoaib [MOD]

    11/13/2022, 11:19 AM
    Question about arrow-proofs: I can see that polymorphic proofs are a thing, so how do you deal with a proof like
    Foo<Foo<T>> -> Foo<T>
    ? That proof is valid in that it's not cyclical, but if you're working backwards from knowing that we need a
    Foo<T>
    then I can't see how to ascertain that this proof isn't applicable (because the proof is applicable if e.g. there's a
    Foo<Foo<Foo<T>>>
    that can be created). One can obviously look at other proofs that provide a Foo of something and use those as a starting point, but what if there's a proof
    Bar<T> -> Foo<T>
    and the only proof returning
    Bar<T>
    requires a
    Foo<Foo<T>>
    (akin to mutual recursion) Also will arrow-proofs support something like
    @Inject fun <A, B> test(@Given bar: Bar<A, B>, @Given foo: Foo<A>): B = bar.someFunctionThatTakesFooAndReturnsB(foo)
    As in, will type parameter be properly substituted in like that and allowed to influence the resolution of what proof to use for
    foo
    , or will the caller have to specify
    A
    and
    B
    for the call to resolve correctly? Looking around the plugin code I can see that for every
    Inject
    function you generate one with default arguments, so I can't really see how this use case could be supported.
    j
    r
    • 3
    • 51
  • l

    Lee Taehoon

    11/14/2022, 7:10 AM
    I wanna generate arrow-optics lens for data class by using plugin https://arrow-kt.io/docs/optics/lens/#generating-lenses It makes lens variable well, but Android Studio can not find the variable
    @optics
    data class Company(val name: String, val address: Address) {
    	companion object
    }
    // Auto generated code
    
    public inline val com.example.contextreceiversample.Company.Companion.name: arrow.optics.Lens<com.example.contextreceiversample.Company, kotlin.String> inline get() = arrow.optics.Lens(
      get = { company: com.example.contextreceiversample.Company -> company.`name` },
      set = { company: com.example.contextreceiversample.Company, value: kotlin.String -> company.copy(`name` = value) }
    )
    
    public inline val com.example.contextreceiversample.Company.Companion.address: arrow.optics.Lens<com.example.contextreceiversample.Company, com.example.contextreceiversample.Address> inline get() = arrow.optics.Lens(
      get = { company: com.example.contextreceiversample.Company -> company.`address` },
      set = { company: com.example.contextreceiversample.Company, value: com.example.contextreceiversample.Address -> company.copy(`address` = value) }
    )
    I tried to reference
    Company.name
    , but Android Studio can not find it. Still, build and run normally. How can I solve this problem? I had tried
    Invalid Caches and Restart
    .
    s
    • 2
    • 2
  • d

    Daniel Berg

    11/15/2022, 11:05 PM
    I’m starting to upgrade a few services from arrow 1.0 to 1.1. It seems that
    either
    and
    either.eager
    are now deprecated? The replacement is
    effect { … }.toEither()
    and
    eagerEffect { ... }.toEither()
    ? Is that right?
    s
    s
    • 3
    • 7
  • r

    Racci

    11/17/2022, 7:34 AM
    So ive been using atomicfu for atomics for a while, is there a difference in performance how they work or any benefits /downsides to arrows atomics compared to atomicfu?
    s
    • 2
    • 6
  • t

    Tom Davis

    11/17/2022, 10:03 PM
    looking to do a transformation of arrow types, but having trouble coming up with a succinct call chain. i have a
    List<() -> Validated<E, A>>
    which i want to transform into
    ValidatedNel<E, A>
    by: 1. specifying invalid value if the list is empty 2. calling items until the first valid value is encountered 3. aggregating invalid values until (2) 4. ignoring items after (2) i can come up with an "ugly" way to do this easily enough, but i'm curious if there's a nice fluent pattern for it. thanks in advance!
    s
    • 2
    • 2
  • j

    Jorge Bo

    11/18/2022, 12:43 PM
    Hi, i need to execute meterService.incrementExitRequests(“online”) always, no matter if there is an error. Is there anything in arrow that works like a finally clause? Not sure if it is the correct approach.
    either<ReservationError, Unit> {
        //do some logic
    }.mapLeft {
        meterService.incrementExitError("online")
        it
    }.map {
        meterService.incrementExitRequests("online")
    }
    p
    s
    • 3
    • 4
  • m

    Marc Plano-Lesay

    11/18/2022, 11:04 PM
    I'm looking to do something pretty simple: I have a boolean expression, if it evaluates to
    true
    , I want to evaluate something and return it as a
    Some
    , otherwise I want to return a
    None
    . Here's a pretty trivial implementation that might be clearer:
    fun <A> Option.Companion.cond(condition: Boolean, value: () -> A): Option<A> = if (condition) {
      value().some()
    } else {
      None
    }
    Is there anything built-in that I'm missing?
    c
    k
    y
    • 4
    • 7
  • j

    Jörg Winter

    11/20/2022, 9:07 AM
    With the existing operators/constructors, I probably could implement a "on/off" switch only, when that switch is evaluated in the function that is passed to
    repeat
    (think
    AtomicBoolean
    or something similar). So the Schedule actually continues, but the effect to be run by
    repeat
    has to evaluate that switch inside it's own logic. What I am looking for is something like an
    pause
    operator, which completely stops the Schedule until some condition gets true again. Is this semantic possible with the current operators somehow or could that be added in the future ?
    s
    • 2
    • 36
  • t

    trevjones

    11/21/2022, 6:31 PM
    Has anyone looked at teaching arrow analysis how to keep track of composition local usages in function body’s to imply the required composition locals. Then i’d imagine the call site of a function could be validated? I’ve not ever used the tool but it seems like the sort of thing it could do after listening to the kotlin talks conversation. For those not working in android land: https://developer.android.com/reference/kotlin/androidx/compose/runtime/CompositionLocal You can sort of think of comp locals as an implicitly available map to pull things from.
    c
    • 2
    • 17
  • e

    Eduardo Barbosa

    11/24/2022, 3:58 PM
    Hey. I have a very "stupid" problem, sorry 😅 So I'm using Arrow with spring boot, and I'm having problems with deserializing Options and Eithers (haven't tested other data types). It seems to be converting the inner state into JSON instead of the "value". I feel like I'm doing something incredibly stupid here. Any hints? I've put more details here with a minimal working example https://github.com/arrow-kt/arrow-integrations/issues/105
    s
    s
    • 3
    • 5
  • c

    chiroptical

    11/25/2022, 3:25 PM
    Hello, looking for some guidance as I am new to Kotlin coroutines/arrow. To get better, I am planning on doing advent of code 2022 using arrow coroutines. To start, I solved last year's day one here: https://github.com/chiroptical/advent-of-code-2022/blob/main/src/main/kotlin/dayOne/DayOne.kt. First, does this look reasonable? I am mostly curious about my approach to
    CoroutineScope.windows
    and
    dayOne
    (there are edge cases in
    strictlyIncreasing
    that aren't important for this conversation). Second, is it possible to fold in parallel as well? I tried creating two actors, passing inputs to them, and then combining them at the end but it just didn't do anything. I am incredibly open to suggestions here🧵
    s
    • 2
    • 21
  • c

    CLOVIS

    11/25/2022, 3:52 PM
    Just wanted to say, I'm always impressed by the Arrow documentation every time I read it. It's really a new standard for the entire ecosystem.
  • k

    Kristian Nedrevold

    11/25/2022, 5:50 PM
    For arrow 2.0 will Option be deprecated?
    s
    c
    • 3
    • 11
  • w

    Wesley Hartford

    11/25/2022, 11:26 PM
    Is there a relationship between the Arrow core type
    Effect
    and the
    arrow-fx
    projects? I've been using
    Effect
    to model effects such as calls to a database or web service. Is there a recommended way to use the features of
    arrow-fx
    to add retries to an
    Effect
    ?
    s
    • 2
    • 5
  • j

    jem

    11/27/2022, 8:48 AM
    Is there a detekt/findbugs for Arrow? I sometimes forget to bind my Eithers and I'd like the build to fail next time I do it
    s
    g
    +3
    • 6
    • 6
  • s

    simon.vergauwen

    11/28/2022, 10:41 AM
    The PR which proposes probably the biggest change from 1.x.x to 2.x.x, removing
    Validated
    and integrating its functionality into
    Either
    . https://github.com/arrow-kt/arrow/pull/2795#issuecomment-1328864003 Feedback, and thoughts are very welcome 🙏
    s
    p
    • 3
    • 18
Powered by Linen
Title
s

simon.vergauwen

11/28/2022, 10:41 AM
The PR which proposes probably the biggest change from 1.x.x to 2.x.x, removing
Validated
and integrating its functionality into
Either
. https://github.com/arrow-kt/arrow/pull/2795#issuecomment-1328864003 Feedback, and thoughts are very welcome 🙏
s

stojan

11/28/2022, 12:39 PM
any thoughts on top level
zip
function instead of the current extension function? I think it existed in earlier versions of arrow but was replaced by extension functions at one point e.g.
zip
and
combine
from kotlinx coroutines are top level functions
s

simon.vergauwen

11/28/2022, 12:48 PM
You mean
zip(fa, fb, fc) { a, b, c -> }
instead of
fa.zip(fb, fc) { a, b, c -> }
?
Curious because in Kotlin Std there are a couple of functions that are extension functions
zip
. I.e. on
Iterable<A>
s

stojan

11/28/2022, 12:59 PM
yeah, but AFIK for
Iterable
example, it's always two of them that are zipped... so extension function makes sense there IMO but when we have them with arity 2-7, top level makes more sense IMO
s

simon.vergauwen

11/28/2022, 1:05 PM
I'm not sure I follow that train of thought 🤔 I wish there were guidelines for this, or that the Jetbrains people would document why these functions are shaped differently in Kotlin Std and KotlinX.
Huh,
combine
is defined as an extension for arity-2 and for arity 3+ it's top-level 🤯 https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/combine.html
The only other top-level are
vararg
which is different, since that doesn't allow independent functions like
Either#zip
.
s

stojan

11/28/2022, 1:10 PM
interesting... didn't notice arity 2 was an extension function... I guess I've always needed more than 2 :D
I wish there were guidelines for this, or that the Jetbrains people would document why these functions are shaped differently in Kotlin Std and KotlinX.
maybe we can ask in the #stdlib channel?
s

simon.vergauwen

11/28/2022, 1:11 PM
It's strange to me that you have to rewrite
flowA.zip(flowB) { a, b -> }
to
zip(flowA, flowB, flowC) { a, b, c -> }
s

stojan

11/28/2022, 1:15 PM
good point, not very refactor friendly for adding an argument
p

phldavies

11/28/2022, 2:15 PM
I found the
Validated<A>.zip(b: V<B>, c: V<C>, (A, B, C) -> R)
odd that it feels like it elevates
A
other the others as different. If you want to rearrange the arguments to the block you end up swapping receivers around.
s

simon.vergauwen

11/28/2022, 2:17 PM
I'm not sure I follow @phldavies. Could you give an example?
p

phldavies

11/28/2022, 3:33 PM
For example (contrived)
val username = fields.required("username").andThen(String::parseUsername)
val email = fields.required("email").andThen(String::parseEmail)
val age = fields.required("age").andThen(String::parseAge)

email.zip(username, age, ::CreateUserRequest)
Why is
email
different to
username
or
age
in this case? If I wanted to updated
CreateUserRequest
to take
username
first, I’d need to update the receiver of
zip
rather than just the argument ordering. It just feels like the first argument being bound is treated specially. For this reason, I sometimes find myself adding a top-level
zip(A, B, C, (a, b, c) -> R)
helper to make it feel a little more natural. As an example, kotest has a top-level
Arb.bind(Gen<A>, Gen<B>, Gen<C>, (a, b, c) -> R) -> Arb<R>
rather than a
Gen<A>.zip(...)
s

simon.vergauwen

11/28/2022, 3:39 PM
Okay, thank you I understand now so
Either.zip(fa, fb, fc) { a, b, c -> }
would make more sense to you? I guess this is similar to what @stojan was saying. One of the original reasoning, besides getting inspiration from
Iterable<A>#zip
was because
fa.zip
is easier to find through auto-completion.
p

phldavies

11/28/2022, 3:50 PM
At least for the use-case of
Validated
I initially looked for an extension off the
Validated
companion, iirc. I can certainly see your reasoning though, given stdlib provides
Iterable<A>.zip(Iterable<B>, (A, B) -> C)
and arrow extends that with n-arity forms with the receiver maintained.
s

simon.vergauwen

11/28/2022, 3:51 PM
Yes, I can see where you're coming from. In FP it's typically defined
mapN(fa, fb, fc) { a, b, c -> }
or with special syntax
fa @ fb @ fc
(returning a Tuple).
s

stojan

11/28/2022, 3:52 PM
I initially looked for an extension off the
Validated
companion
AFIK the companion object strategy is not used in the standard lib or kotlinx coroutines, and the kotlin team suggests top level functions instead
View count: 9