Core Libraries

Arrow is a modular set of libraries that build on top of each other to provide increasingly higher level features.

One of our design principles is to keep each library as lean as possible to avoid pulling unnecessary dependencies, specially to support Android development where app size affects performance. You’re free to pick and choose only those libraries that your project needs!

In this doc we’ll describe all the modules that form the core, alongside a list of the most important constructs they include.

arrow-core

beginner

The smallest set of constructs necessary to start in FP, and that other libraries can build upon. The focus here is on API design and abstracting small code patterns.

Datatypes: Either, Option, Try, Eval, Id, TupleN, Function0, Function1, FunctionK

arrow-syntax

beginner

Multiple extensions functions to work better with function objects and collections.

Dependencies: arrow-core

For function objects the library provides composition, currying, partial application, memoization, pipe operator, complement for predicates, and several more helpers.

For collections, arrow-syntax provides firstOption, tail, basic list traversal, and tuple addition.

arrow-typeclasses

intermediate

All the basic typeclasses that can compose into a simple program.

Dependencies: arrow-core

Datatypes: Const

Typeclasses: Alternative, Bimonad, Inject, Reducible, Traverse, Applicative, Comonad, Eq, Monad, Monoid, Semigroup, ApplicativeError, Foldable, MonoidK, SemigroupK, Bifoldable, Functor, MonadError, Order, Show, Composed

arrow-data

beginner

This library focuses on expanding the helpers provided by typeclasses to existing constructs, like the system collections. You can also find more advanced constructs for pure functional programming like the RWS datatypes, or transformers.

Dependencies: arrow-typeclasses

Datatypes: Cokleisli, Coreader, Ior, ListK, NonEmptyList, SequenceK, SortedMapK, StateT, WriterT, Coproduct, EitherT, Kleisli, MapK, OptionT, Reader, SetK, State, Validated

arrow-instances-(core, data)

intermediate

These two libraries include the possible typeclass instances that can be implemented for the datatypes in arrow-core and arrow-data, and some basic types.

Dependencies: arrow-typeclasses, and either arrow-core or arrow-data

arrow-mtl

advanced

Advanced typeclasses to be used in programs using the Tagless-final architecture.

It also includes the instances available for datatypes in both arrow-core and arrow-data

Dependencies: arrow-instances-data

Typeclasses: FunctorFilter, MonadFilter, MonadReader, MonadWriter, MonadCombine, MonadState, TraverseFilter

Extension libraries

These libraries are hosted inside the arrow repository building on the core, to provide higher level constructs to deal with concepts rather than code abstraction.

arrow-optics

beginner

Optics is the functional way of handling immutable data and collections in a way that’s boilerplate free and efficient.

It can be used alongside annotation processing to generate simple DSLs that read like imperative code.

For all the new typeclasses it also includes the instances available for basic types and datatypes in both arrow-core and arrow-data.

Datatypes: Fold, Getter, Iso, Lens, Optional, Prism, Setter, Traversal

Typeclasses: At, Each, FilterIndex, Index

arrow-effects

intermediate

The effects library abstracts over concurrency frameworks using typeclasses. Additionally it provides its own concurrency primitive, called IO.

Datatypes: IO

Typeclasses: MonadSuspend, Async, Effect

arrow-effects-(rx2, reactor, kotlinx-coroutines)

intermediate

Each of these modules provides wrappers over the datatypes in each of the libraries that implement all the typeclasses provided by arrow-effects

Rx: Observable, Flowable, Single

Reactor: Flux, Mono

kotlinx.coroutines: Deferred

arrow-recursion

advanced

Recursion schemes is a construct to work with recursive data structures in a way that decuples structure and data, and allows for ergonomy and performance improvements.

Datatypes: Fix, Mu, Nu

Typeclasses: Corecursive, Recursive, Birecursive

arrow-free

advanced

The Free datatype is a way of interpreting domain specific languages from inside your program, including a configurable runner and flexible algebras. This allows optimization of operations like operator fusion or parallelism, while remaining on your business domain.

Datatypes: Free, FreeApplicative, Cofree, Yoneda, Coyoneda

Annotation processors

These libraries focus on meta-programming to generate code that enables other libraries and constructs.

arrow-generic

advanced

It allows anonating data classes with @product to enable them to be structurally deconstructed in tuples and heterogeneous lists.