Bringing functional programming to Kotlin with Arrow
There’s a new library in town! Arrow is a functional companion to Kotlin’s Standard Library. Let’s have a look at some of the major features in Arrow.
Bringing functional programming to Kotlin isn’t immediately a nonstarter. While, OOP is always implicit when we think about Kotlin, it’s not entirely necessary. Some of Kotlin’s built in features like high order functions or the power to use functions as first class citizens. They are obviously function-aligned, if not entirely a part of “Functional Programming”.
Arrow is a library for typed functional programming in Kotlin. It includes the most popular data types, type classes and abstractions such as Option, Try, Either, IO, Functor, Applicative, Monad and many more empowering users to define pure FP apps and libraries built atop higher order abstractions.
Born from the two most popular functional programming Kotlin libraries, KΛTEGORY and funKTionale, Arrow has created an improved FP ecosystem for everyone in Kotlin. No longer dispersed across several libraries, Arrow provides users in Kotlin a unified and reasonable approach to typed FP. This approach avoids issues related to split libraries and binary incompatibilities between data types and type classes for users.
Here are some of the major features in Arrow:
- Patterns – A list of tutorials and FP patterns demonstrating solutions to common programming tasks in a pure FP way.
- Type classes – Functor, Applicative, Monad, and all their friends so you can take advantage of ad-hoc polymorphism in Kotlin.
- Data types – Option, Try, Either, Eval, NonEmptyList and many other data types based on algebraic properties.
- Integrations – Integrations with Rx2 and other popular frameworks and data types in the Kotlin ecosystem.
- Optics – Inspecting and modifying data structures.
Arrow was designed and built as a modular library. This approach allows users to pick and choose which features they liked the most. As of the current release 0.5.5, here are some of the following modules that are available:
- Effects RX2