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

    Jannis

    02/22/2019, 8:49 PM
    Is there any reason that
    @extension
    here does not work?
    @higherkind
    class Test<A>(val f: () -> A): TestOf<A> {
        companion object {}
    }
    
    @extension
    interface TestFunctor : Functor<ForTest> {
        override fun <A, B> Kind<ForTest, A>.map(f: (A) -> B): Kind<ForTest, B> =
            Test { f(fix().f()) }
    }
    This fails with
    kaptKotlin
    reporting `e: error: Arrow's annotations can only be used on Kotlin classes. Not valid for error.NonExistentClass``But aren't pretty much all instance declared this way? What am I missing here?
    r
    • 2
    • 7
  • p

    pakoito

    02/23/2019, 1:05 AM
    @Jannis data class Test?
    j
    • 2
    • 5
  • h

    Hexa

    02/24/2019, 9:05 AM
    is there a better way to write this without using the
    try catch
    override fun f1(): Either<Errors.ApplicationError, AWSClient> =
                Try {
                    try {
                        // logic1 here
                    } catch (ex: Exception) {
                       // if logic1 throws exception then try logic2 in here
                    }
                }.toEither().mapLeft {
                    (Errors.UnexpectedError("Unexpected error: ${it}"))
                }
    k
    k
    r
    • 4
    • 5
  • z

    zsmb

    02/24/2019, 5:59 PM
    Hey everyone, I'm dabbling with extensions, and I'm trying to get something to work based on an example in the docs:
    interface Eq<F> {
        fun F.eqv(b: F): Boolean
        fun F.neqv(b: F): Boolean = !eqv(b)
    }
    
    data class User(val id: Int) {
        companion object
    }
    
    @extension interface UserEq : Eq<User> {
        override fun User.eqv(b: User): Boolean = id == b.id
    }
    Now, I can make the
    neqv
    call work, as that extension is generated:
    val user1 = User(1)
    val user2 = User(2)
    
    user1.neqv(user2)
    However, I don't get an
    eqv
    extension generated. I did get an
    eq
    extension that I could then open a scope on with
    run
    , but this isn't very neat:
    User.eq().run {
        user1.eqv(user2)
    }
    So... Is there something I could fix in my code to make Arrow generate the
    eqv
    extension that I could use like this?
    user1.eqv(user2) // right now, unresolved reference: eqv
    k
    r
    • 3
    • 5
  • p

    pakoito

    02/26/2019, 3:55 PM
    @streetsofboston Raul is looking into that! I don’t know if he has a repro yet 😕
    s
    r
    k
    • 4
    • 27
  • i

    Imran/Malic

    02/26/2019, 5:23 PM
    https://arrow-kt.io/docs/effects/fx/
    p
    • 2
    • 7
  • s

    simon.vergauwen

    02/28/2019, 8:06 AM
    If so can you check if any code is generated by kapt?
    i
    p
    r
    • 4
    • 14
  • p

    pakoito

    03/01/2019, 10:15 PM
    right, because destructuring only works with fx
    k
    • 2
    • 1
  • r

    raulraja

    03/01/2019, 10:59 PM
    it is deprecated in favor of
    fx
    in 0.9.0
    k
    • 2
    • 3
  • r

    raulraja

    03/02/2019, 1:03 PM
    @takahirom there is no need to the explicit unsafeRun there. You can use
    fxCancellable
    if you wish to obtain a cancel token alongside your program:
    t
    • 2
    • 1
  • r

    raulraja

    03/02/2019, 1:04 PM
    fxCancellable.kt
    👍 3
    p
    t
    • 3
    • 10
  • h

    HieiJ

    03/04/2019, 9:30 PM
    ok! I'm a little curious about how are you going to expose these apis also inside suspend functions 😬
    r
    • 2
    • 7
  • r

    reik.schatz

    03/05/2019, 2:37 PM
    fun foo(): Try<Unit> {
        return Try {
            1 // doesn't compile
        }
    }
    b
    r
    • 3
    • 20
  • s

    sitepodmatt

    03/06/2019, 4:09 PM
    do you know a relatable scenario where one would use ap on an Either
    d
    • 2
    • 8
  • p

    pakoito

    03/08/2019, 1:17 PM
    there’s no need to bend and twist it when it’s this simple 😄
    👍 5
    s
    • 2
    • 1
  • r

    raulraja

    03/09/2019, 5:39 PM
    Passing the Applicative won't be necessary if KEEP-87 makes it to Kotlin.
    s
    k
    • 3
    • 14
  • s

    stojan

    03/10/2019, 6:01 PM
    okay...
    bind()
    still works 🙂
    k
    • 2
    • 3
  • s

    stojan

    03/10/2019, 6:39 PM
    I have to copy-paste the import
    r
    • 2
    • 1
  • d

    Danilo Herrera

    03/11/2019, 6:04 PM
    I guess I'm wondering if there's a more "common" (or existing) way of doing the following:
    sealed class Cargo<T> {
      class Loading<T> : Cargo<T>()
      data class Loaded<T>(val cargo: T) : Cargo<T>()
      data class Error<T>(val cargo: T) : Cargo<T>()
    }
    p
    s
    • 3
    • 2
  • r

    raulraja

    03/12/2019, 4:16 PM
    We do have comonadic data types in arrow extras. Day, Moore etc. but we still lack a well defined recommended pattern to build purely functional UIs
    p
    p
    • 3
    • 7
  • j

    janvladimirmostert

    03/13/2019, 12:46 PM
    quick question, can Arrow be used with KotlinJS and Native ?
    r
    • 2
    • 3
  • h

    Hexa

    03/15/2019, 3:30 PM
    I got a function like this.
    override fun getCar(name: String): Either<CarNotFound, String?> {
            val carAttributes = loadCarAttributes(name)
            return when (carAttributes) {
                is Either.Right -> {
                    return Right(carAttributes.b.attributes["carId"])
                }
                is Either.Left -> {
                    Left(CarNotFound("car not found"))
                }
            }
        }
    When I call that function I want to access the values so that if the value is Left then I just return CarNotFound to the client. Else I use the value on the Right (which is just a string) to do further processing. I tried something like this but it didnt't work
    val carType = getCar("testname").fold( 
                            return Left({CarNotFound(it.message)}),
                            {it})
                    )
    m
    s
    • 3
    • 14
  • b

    Bob Glamm

    03/18/2019, 7:55 PM
    no rush on it 🙂
    👍 1
    r
    • 2
    • 5
  • j

    jeremy

    03/20/2019, 1:11 AM
    Is there anything that might allow me to take a List<String> and convert it to a List<Tuple2<String, String>> where it pairs elements and if odd <String, Null> ?
    s
    • 2
    • 3
  • e

    earroyoron

    03/20/2019, 8:59 AM
    Sorry I forgot this is an english Channel! 🤭 IHello everybody, as I am starting in Kotlin in its aspect of functional programming (Arrow) and as I am 99% backend, my first thoughts are like FP in a hexagonal architecture, with the ports&adapters for the side-effects and the pure domain (arrow powered) in functional is, perfect? (if there is such a perfect term in architecture) Any experience with this architecture in backends?
    🇪🇸 1
    r
    • 2
    • 2
  • b

    Bob Glamm

    03/20/2019, 1:27 PM
    I don't think I'm smart enough to join that channel yet
    r
    m
    • 3
    • 2
  • j

    Jannis

    03/25/2019, 2:28 PM
    Neither is a bifunctor if I understood that concept correctly. I think its best described by looking at the type signature of bimap (haskell and arrow):
    (a -> b) -> (c -> d) -> p a c -> p b d
    and arrow
    fun <A, B, C, D> Kind2<F, A, B>.bimap(fl: (A) -> C, fr: (B) -> D): Kind2<F, C, D>
    . So the intuition is its basically a functor applied to both type arguments. Fold looks more like this (for option):
    (() -> b) -> (a -> B) -> Maybe a -> b
    fun <A, B>Option<A>.fold(none: () -> B, some: (A) -> B): B
    and either is similar. Fold destructures while bimap keeps structure. If you are looking for types that are bifunctors and their uses:
    Either
    has a bifunctor instance,
    Ior
    should have one and I think soon we'll have
    IO
    be parameterized to
    IO<E, A>
    and that should be a bifunctor as well
    ➕ 3
    👍 1
    k
    • 2
    • 5
  • f

    Fabian

    03/26/2019, 8:38 AM
    Fixed in #40
    😢
    r
    • 2
    • 1
  • c

    carlos cdmp

    03/28/2019, 10:15 AM
    val (resultKind, disposable) =
                    fxCancellable {
                        getAllCharactersCase.execute()
                    }
            myDisposable = disposable
            val result: Try<CharacterList> = ...
            result.fold(
                ifFailure = {
                    println(it.message)
                },
                ifSuccess = {
                    displayResult(it)
                }
            )
    r
    • 2
    • 8
  • r

    raulraja

    03/28/2019, 10:35 AM
    Once_on__IO__we_never_need__Try_.kt
    👌 2
    c
    • 2
    • 3
Powered by Linen
Title
r

raulraja

03/28/2019, 10:35 AM
Once_on__IO__we_never_need__Try_.kt
👌 2
c

carlos cdmp

03/28/2019, 10:39 AM
This like a whole new world to me, thanks for the example
r

raulraja

03/28/2019, 10:41 AM
No problem, spread the good word, people are confused about Try and Either, they can't control effects, only IO can or any
MonadDefer
capable data type like Observable, etc
https://arrow-kt.io/docs/effects/fx/
View count: 3