Functional Programming in Kotlin with Arrow Library

This program is designed for experienced developers who want to improve their functional programming knowledge. The delivery expects knowledge of the Kotlin language and expands on it, allowing developers to take advantage of the Arrow library’s additional features. 


In this workshop, participants will design and implement sample applications, which follow the Functional Programming style. To boost safety and maintainability, they’ll leverage functional types like Either, Validated, and State. The more complex FP operators, such as traverse and bimap, will be used to implement algorithms. Attendees will be able to use Effects to create polymorphic programs that can run in a variety of settings by the end of this course.


What You’ll Learn

➜ The purposes and advantages of Coroutines

➜ Effectively leverage all aspects of Coroutines Library

➜ How to use coroutines for asynchronous programming

➜ Coroutines + Retrofit + MVVM

➜ Coroutines and Android Background processing 

 Coroutines flow in an Android app


➜ We recommend that attendees of this course are confident with Kotlin programming language or similar Functional Programming-oriented languages, with experience in industry.

➜ Familiarity with coroutines, structured concurrency, coroutine scopes, dispatchers, cancellation, suspend and Flow is also recommended.


Course Outline

Kotlin Functional Programming Fundamentals 

  • How to work with function references and lambdas
  • Lambdas with receiver and patterns for DSL’s
  • How to declare functions as parameters and return types
  • Partial Invocation and Currying
  • Choosing between code blocks and local functions
  • Common misunderstandings about enclosure

Advanced Functional Programming Concepts 

  • Programming using Algebraic Data Types in Kotlin
  • How to add operators to data structures via Typeclasses
  • Abstracting generic types via Higher Kinded Types
  • Functional composition and rules for monadic types
  • How to combine different monadic types via Transformers

Functional Types Supported in Arrow

  • The Identity type and situations where it is useful
  • Understanding why the Option and Try types are not needed in Kotlin
  • Modelling exceptions and cached/default values via Either
  • Collecting errors via the Validated type and Semigroups
  • Using the Reader type to build a record across invocations
  • Using the State / Writer type to pass data between calls
  • Arrow wrappers to Kotlin collections and NonEmptyList

Additional Operators Supported by Arrow

  • Inverting collections of monadic types via traverse
  • Using Applicatives to hande multiple type instances
  • Composition in Arrow using suspending functions
  • Kleisli as an alternative means of composition
  • Applying fold, bimap and swap to Monadic Types

Manipulating Immutable Data with Optics

  • Problems posed by deep nesting in immutable collections
  • Advantages and limits of data classes and the copy method
  • Using Optics to focus on specific fields in nested data
  • Different forms of Lens in Arrow, and how to create them
  • Maintaining codebases that use the Optics library heavily

Building Purely Functional Designs with Effects

  • Why pure functions are desirable but side effects inevitable
  • How the IO type can be used to separate pure from impure code
  • Effects libraries, delimited continuations and effectful coding
  • Understanding Polymorphic Programs within functional designs
  • How Arrow 1.x uses suspending functions instead of an IO type
  • Emerging patterns for building applications using Effects