# KotlinConf'23-Kotlin & Functional Programming: pick the best, skip the rest by Urs Peter

DevFeed: [KotlinConf'23-Kotlin & Functional Programming: pick the best, skip the rest by Urs Peter](<https://devfeed.tech/articles/kotlinconf-23-kotlin-functional-programming-pick-the-best-skip-the-rest-by-urs-peter-27026.md>)

Original publisher: [Read original article](<https://appmattus.medium.com/kotlinconf23-kotlin-functional-programming-pick-the-best-skip-the-rest-by-urs-peter-8958d3dcb432?source=rss-be40b368c57e------2>)

Author: Matthew Dolan

Published: 2023-04-14T06:32:47Z

Content type: opinion

Language: en

Sources: [Stories by Matthew Dolan on Medium](<https://devfeed.tech/sources/stories-by-matthew-dolan-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [exceptions](<https://devfeed.tech/topics/exceptions.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [arrow](<https://devfeed.tech/tags/arrow.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [functional-programming](<https://devfeed.tech/tags/functional-programming.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [monad](<https://devfeed.tech/tags/monad.md>), [optional](<https://devfeed.tech/tags/optional.md>), [programming](<https://devfeed.tech/tags/programming.md>)

## AI overview

A review of Urs Peter's KotlinConf'23 talk on functional programming, covering monoids, functors, monads, and selective use of the Arrow framework. It highlights using Either for recoverable service errors, nullable comprehensions, and Arrow Optics for nested data updates.

## Source excerpt

KotlinConf'23 -- Kotlin & Functional Programming: pick the best, skip the rest by Urs Peterhttps://medium.com/media/b5b95f6bdbb507930534ef8279ba1d05/href I recently had the pleasure of listening to Urs Peter's talk on Kotlin & Functional. The speaker gave a great, simple summary of what a Monad is and how it works. In essence: a Monoid is combinable (plus) and has an identity (empty) element which when combined with another value returns that other value. a Functor is mappable (map) a Monad is composable (flatMap) The talk then went on to discuss some common monads, such as Collections and Optional. The highlight of the talk for me was when the speaker talked about cherry-picking the best features between Kotlin and Monads (using the Arrow framework). Use Monads selectively where needed and useful. Why use a Monad to replace try-catch blocks for the 95% of use cases? Let exceptions bubble up to a GlobalExceptionHandler. For the other 5%, where we're typically recovering in our service, prefer Either<A,B> over Result as it makes the contract explicit with easy access to the error reply. Prevent tedious null checks with Arrow's nullable{ } comprehension. With deeply nested data structures where you want to change something at the leaf level, use Arrow Optics instead of nested copy calls. While I enjoyed the talk, I would have loved to hear more best features. You can find my thoughts on more KotlinConf'23 talks at KotlinConf'23. Please let me know your thoughts. Join medium to read all of my articles or subscribe for e-mail updates.