Connecting...

W1siziisijiwmjavmdyvmjmvmtuvndqvmtavmtkzl2dyyxlzy2fszs1wag90b2dyyxboes1vzi1wzw9wbgutd2fsa2luzy1vbi13ywxrywxhdg9yltiwodexnjyuanbnil0swyjwiiwidgh1bwiilciyntywedm4mcmixv0

What's Ap? by Justin Heyes Jones

W1siziisijiwmjavmdyvmjmvmtuvndqvmdgvotqyl2dyyxlzy2fszs1wag90b2dyyxboes1vzi1wzw9wbgutd2fsa2luzy1vbi13ywxrywxhdg9yltiwodexnjyuanbnil0swyjwiiwidgh1bwiilci5mdb4otawxhuwmdnlil1d

This talk was given by Justin Heyes Jones at the Scala Love online conference.



What's Ap? Applicative is a lesser know type class that lies between Functor and Monad in terms of power. In this talk, which presumes no previous experience of pure functional programming, I will talk about how flatMap and map are familiar to most Scala programmers and how they relate to Functors and Monads from category theory. Next, I will show where the Applicative type class fits into the picture, particularly how it can be used in your programs to do things that are not possible with Functor or Monad. Looking at the ap function in detail I’ll show how it is applied to different effect types from List and Option to Reader and IO, and show the motivation for its existence in the Cats library. Next, I’ll show how Applicative lets us work on multiple effects and pass them to pure functions, how to run independent effects concurrently to do things like compose images and make calls to external services. Finally, a look at how to efficiently implement an Applicative instance to avoid redundant work, by taking advantage of the fact that we can implement Applicative using different primitives depending on the effect type.