DroidJam India '18 Arrow and functional programming for Kotlin developers

DroidJam India '18 Arrow and functional programming for Kotlin developers

In this talk, I’ll be describing Functional Programming in Kotlin, and Arrow library for Android Developers, taking some extracts from my book Functional Kotlin. Functional Programming is the most trendy thing nowadays as well as the most evolved paradigm.


Rivu Chakraborty

July 13, 2018


  1. Functional Programming in Kotlin - Android DroidJam India 2018 Rivu

  2. Rivu Chakraborty • A learner • Sr. Software Engineer (Android)

    @ Indus Net Technologies Pvt. Ltd. • Community Lead: GDG Kolkata, Kotlin Kolkata • Instructor @ Caster.io • Author – Reactive Programming in Kotlin • Author – Functional Kotlin • Author – Coroutines for Android Developers (WIP) • Author – Hands on Data Structures & Algorithms in Kotlin (WIP) @rivuchakraborty
  3. 50% off on EBook 15% off on Print Book RPKFK50

    RPKFK15 https://www.packtpub.com/application- development/reactive-programming-kotlin https://www.packtpub.com/application- development/functional-kotlin
  4. What is Functional Programming? • Representation of Mathematical Function State

    Traditional / Imperative / Von Neuman Style Input Output
  5. Why Functional Programming • Modulation of code • FP encourages

    safe ways of programming through Immutability & Pure Functions • Testing becomes easier • Programs are easier to read.
  6. What are Functional Languages? • Any language that gives support

    to Functions as first class citizens are called Functional Language.
  7. Pure Functions • Same return value for same input, can

    be cached • Doesn’t modify anything outside function scope (No side effects) fun square(n:Int):Int { return n*n }
  8. Immutability • Immutability != Read Only • Kotlin doesn’t force

    Immutability, it encourages Immutability • The val keyword doesn’t guarantees immutability
  9. Lambda • To be generic, lambda or lambda expressions generally

    means anonymous functions, that is, functions without names, which can be assigned to variables, passed as arguments, or returned from another function fun invokeSomeStuff(doSomeStuff:()->Unit) { doSomeStuff() } fun main(args: Array<String>) { invokeSomeStuff { println("doSomeStuff called"); } }
  10. Arrow • Functional companion to Kotlin’s Standard Library

  11. Type Constructors • Type Constructors are mainly theoretical concept. It’s

    not a Kotlin class constructor building a type. • We can reference Generic Parameterised Types as Type Constructors List<T> Map<K,T> Option<T> Either<L,R>
  12. Type Constructors • Option • Either • Try

  13. Type Classes • Type classes encode behaviour • You can

    use typeclasses as a DSL to access new free functionality for an existing type, or treat them as an abstraction placeholder for any one type that can implement the typeclass. The extension functions are scoped within the typeclass so they do not pollute the global namespace! • Example: Monads, Functors, Applicatives
  14. Monads, Functors, Applicatives

  15. This Photo by Unknown Author is licensed under CC BY-NC-ND

    @rivuchakraborty Rivu Chakraborty