Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DroidJam India '18 Arrow and functional program...

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
Tweet

More Decks by Rivu Chakraborty

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. What is Functional Programming? • Representation of Mathematical Function State

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

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

    to Functions as first class citizens are called Functional Language.
  6. 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 }
  7. Immutability • Immutability != Read Only • Kotlin doesn’t force

    Immutability, it encourages Immutability • The val keyword doesn’t guarantees immutability
  8. 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"); } }
  9. 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>
  10. 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