liveBook · Manning

Applicative functor

An applicative functor is a functor with operations for applying a function in a computational context to a value in that context and combining the computations.

How 4 Manning books explain it

Functional Programming in Scala, Second Edition

An applicative functor is an abstraction that applies effectful functions to effectful arguments while combining their contexts.

How it is used
Combines independent effectful values and supplies the effect interface required by generic traversal.
How deep it goes
Defines `unit`, `map2`, and `apply`; contrasts monadic dependency and states identity, associativity, and naturality laws.
Examples
Uses Option map lookups, fixed and header-driven CSV parsers, validation, and State-based indexing traversals.
What you can do after
Build it from scratch by implementing `unit` and `map2` or `apply`, then deriving traversal and higher-arity combinators.

Read how Functional Programming in Scala, Second Edition explains applicative functor →

Learn Haskell by Example

Applicative is a Haskell type class for applying functions in a computational context to values in that context and sequencing the resulting computations.

How it is used
Composes fixed sequences of effectful parser actions into structured results.
How deep it goes
Defines `pure`, `(<*>)`, and helper operators, then implements an Applicative instance for a custom Parser.
Examples
Demonstrates Maybe arithmetic, Hello World parsing, and PNM Header parsing.
What you can do after
Build it from scratch, implement and use an Applicative Parser for fixed-format input.

Read how Learn Haskell by Example explains applicative functor →

The Coder Cafe

An applicative is a functional abstraction that applies a function held in a context to a value held in a context, supporting the combination of independent contextual computations.

How it is used
Combines independently wrapped computations, including validations, without manually removing their contexts.
How deep it goes
Works through Maybe and list application, context matching, and a failing greeting attempt; stops short of formal laws.
Examples
Uses a Maybe-wrapped increment, lists of functions and values, and an age-validated greeting that fails to type-check.
What you can do after
Apply it via Haskell’s <*> and <$> to combine independent wrapped inputs and recognize when types or dependencies prevent that combination.

Read how The Coder Cafe explains applicative functor →

Functional Programming in C#, Second Edition

An applicative functor is a functor that supports applying a function in a computational context to a value in that context.

How it is used
Uses applicatives to apply multi-argument functions to values in a computational context.
How deep it goes
Works through Apply implementations and relationships to Map and Bind, while deferring the four applicative laws.
Examples
Illustrates multiplication with Option and parallel airline-fare comparison with Task.
What you can do after
Builds Apply for Option and Task, then applies it to wrapped values and independent asynchronous operations.

Read how Functional Programming in C#, Second Edition explains applicative functor →

Also covered in

What to know first

Related concepts

Questions about applicative functor

What is applicative functor?

An applicative functor is a functor with operations for applying a function in a computational context to a value in that context and combining the computations.

Which Manning books explain applicative functor?

Functional Programming in Scala, Second Edition, Learn Haskell by Example, The Coder Cafe and Functional Programming in C#, Second Edition.

What should I know before learning applicative functor?

Manning books that teach applicative functor usually introduce functor, option, list and Either first.

What is the difference between applicative functor and monad?

An applicative functor is a functor with operations for applying a function in a computational context to a value in that context and combining the computations. A monad is a programming abstraction that provides operations for sequencing computations while encapsulating and preserving their computational context.

What is applicative functor a kind of?

Applicative functor is a kind of functor. A functor is an abstraction that maps values or objects while preserving the structure and relationships of their surrounding context.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.