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
functional
  • r

    raulraja

    05/24/2017, 7:34 PM
    But we want to get rid of that because I can do that with a compiler plugin if I can intercept the AST before it expands and auto register instances
    v
    • 2
    • 2
  • b

    breandan

    06/13/2017, 10:17 AM
    This SO answer https://stackoverflow.com/a/35164370/1772342 provides a lazy concatenation method by defining a custom extension function on
    Sequence
    , but why isn't the operand of
    Sequence.plus(...)
    evaluated lazily by default? Are there any plans to provide this behavior? Is there a way to use the stdlib functions to get a truly lazy implementation for concatenation of Iterables? @h0tk3y
    h
    • 2
    • 3
  • d

    Dalinar

    06/25/2017, 8:46 PM
    sorry guys, I was tired when I posted
    anyMatch
    was a typo, I meant
    all { }
    and
    allMatch { }
    @kevinmost @arocnies
    k
    • 2
    • 3
  • r

    raulraja

    10/02/2017, 3:39 PM
    @elizarov @gildor Would you like us to contribute the KEEP and submit a PR to https://github.com/Kotlin/KEEP for further discussion? I'm not sure about the process but we are very much interested in this feature.
    e
    g
    • 3
    • 3
  • s

    simon.vergauwen

    10/02/2017, 6:34 PM
    I think
    Int.Companion.empty()
    and auto creation of
    Companion
    makes more sense
    ➕ 1
    r
    • 2
    • 1
  • n

    noone

    10/25/2017, 12:11 PM
    I am reading “An introduction to Functional Programming through Lambda Calculus” what does this expression mean? T := X; X := Y; Y := T
    k
    • 2
    • 2
  • d

    dh44t

    12/22/2017, 9:47 AM
    My first book with @rivu.chakraborty
    🎉 3
    🔖 1
    👏 7
    m
    • 2
    • 2
  • t

    tschuchort

    01/22/2018, 11:14 PM
    Would you not agree that runA is a pretty obscure name, regardless of whether it's already used in Scala? I think it would be better to use more explicit names. I'm generally wary of names that rely on convention, although its not always feasable to avoid. For example Factory, Visitor and so on are also a convention and relatively meaningless on their own, but at least you can take a good guess. This however, seems like a very clear cut case to me where the API can be made much more friendly at very little cost, not to mention that FP developers shoukd have no problem adopting to simple naming changes when theyre already familoar with the concepts (the reverse is decidedly not true for OOP devs)
    i
    • 2
    • 2
  • r

    raulraja

    01/25/2018, 1:05 PM
    https://twitter.com/Lambda_World/status/956512786791747584
    😀 1
    😱 2
    i
    • 2
    • 3
  • y

    yaakov

    01/27/2018, 7:14 PM
    Speaking of static typing, are there any static functional languages on the JVM?
    a
    c
    +2
    • 5
    • 9
  • r

    raulraja

    02/15/2018, 12:09 PM
    For those of you getting initiated into FP and wanting to learn what you can use
    Try
    for: https://twitter.com/arrow_kt/status/964099546103123969
    b
    t
    p
    • 4
    • 3
  • g

    gildor

    02/21/2018, 10:06 AM
    also for cases like
    fold
    , I would like to create 0 object instead of 2
    • 1
    • 1
  • r

    raulraja

    02/21/2018, 10:07 AM
    The core module is pretty small and as for the Try constructor we can make those inline if it doesn't break other stuff
    👍 2
    g
    • 2
    • 1
  • p

    pakoito

    02/21/2018, 10:09 AM
    it keeps a copy of the method + one copy per callsite
    g
    • 2
    • 1
  • g

    gildor

    02/21/2018, 10:34 AM
    I like this pattern a lot, I even include own implementation of Result class (with value, HttpError and Exception cases) to my kotlin-coroutines-retrofit adapter, because it’s much more pleasant and safe to use something like this with coroutines (and not only with coroutines, but with any IO code)
    c
    • 2
    • 8
  • g

    gregd

    02/26/2018, 7:23 PM
    Hi 🙂 Another FP newbie here 😉 And one thing bothers me: what type/container should I use to represent a single value that’s neither optional nor can fail in any way, but I still want to
    map
    over it? I know I could use Kotlin’s
    let
    , but maybe there’s a proper FP way of doing this?
    a
    • 2
    • 1
  • r

    raulraja

    02/26/2018, 9:59 PM
    Most people start with the basic data types but IMO the killer feature in Arrow is Ad-Hoc Polymorphism, if you depend on type classes and perform only Effects in the monadic context of
    F
    you can create entire pure programs that entirely independent of the runtime data types that backs their declaration.
    g
    • 2
    • 5
  • t

    tschuchort

    03/06/2018, 4:24 PM
    How would that help? The background service updates latest posts (i.e. at the top of the list) while the pagination loads additional old posts (i.e. at the bottom of the list). I don't even really care about this specific scenario, the app only exists to come up with a scaleable functional architecture that can deal with such problems (like synchronizing parent and child state)
    a
    • 2
    • 3
  • m

    marcinmoskala

    04/14/2018, 4:19 PM
    I understand the problem when we cannot modify
    Color
    , but it is not such a common case + probably in the future we will be able to use extension interfaces.
    a
    b
    • 3
    • 5
  • r

    Robert Menke

    04/17/2018, 2:27 AM
    Don’t you need to instantiate IntAddMonoid and IntMultiplyMonoid at the bottom there?
    g
    a
    t
    • 4
    • 5
  • k

    kenkyee

    07/10/2018, 1:11 PM
    So in Rxjava terms, a Monad is the lambda inside the .map operator?
    r
    a
    +2
    • 5
    • 15
  • n

    Niels Renard

    07/12/2018, 6:57 AM
    I feel like I'm missing something here, how do I return a function from a function?
    g
    • 2
    • 1
  • n

    Niels Renard

    07/12/2018, 7:02 AM
    want to have something like fun funGenerator(some flags) { if flag = a return fn(param) { some operation on param } if flag = b return fn(param1 param2} {some different operations } }
    g
    p
    • 3
    • 11
  • g

    gildor

    07/28/2018, 6:23 PM
    It’s not true. Inline functions still exist in bytecode, so you cannot mark function as inline and decrease methods count Impact of methods count on performance is very limited and hardly measurable. Dex size is important for application startup time, but it’s not only about methods count. Also inline functions will increase dex size, not decrease, especially if you inline functions with big body. And inline functions is not something related only to functional programming, so even with other inline functions advantages it doesn’t look like argument for functional programming
    👍 1
    w
    • 2
    • 1
  • g

    gildor

    07/28/2018, 6:34 PM
    The only point which “indirectly improve performance” that I see is that functional style is much easier to use with asynchronous code and convertatation of synchronous functional code to asynchronous is much more simple thing than refactoring of syncronous imperative to asyncronous. Same with concurrency. So it can improve general performance when you use more asynchronous and concurrent operations and do not block the main thread.
    👍 1
    s
    • 2
    • 2
  • o

    ossama

    07/30/2018, 9:36 AM
    Thanks @simon.vergauwen So. it can’t be done without specifying the f signature?
    s
    • 2
    • 2
  • m

    Marc Reichelt

    08/10/2018, 8:30 AM
    It would be nice to remove
    newDogsMap[it.key]!!
    specifically…
    • 1
    • 1
  • g

    gregd

    12/02/2018, 10:53 AM
    Hi guys! Is there any way to exit-early/short-circuit from the
    reduce
    function? I wan’t to reduce an infinite sequence of numbers, but only until some condition is met (based on the result of the reduce). I know Clojure has this neat
    reduced
    function for this. In Haskell we could use
    scan
    . But do we have anything similar in Kotlin’s stdlib?
    a
    u
    p
    • 4
    • 3
  • p

    pavel

    12/20/2018, 11:36 PM
    or even
    fun testFun(nums: IntArray) =
        nums.fold(Int.MIN_VALUE to Int.MAX_VALUE) { (largest, smallest), next ->
            max(largest, next) to min(smallest, next)
        }.run { first - second }
    h
    u
    d
    • 4
    • 7
  • p

    pakoito

    12/22/2018, 12:59 AM
    is that really iterating through the array?
    s
    • 2
    • 1
Powered by Linen
Title
p

pakoito

12/22/2018, 12:59 AM
is that really iterating through the array?
s

Shawn

12/22/2018, 1:03 AM
they’re using it to subscript the array so
View count: 2