Traverse
traverse is an operation that applies an effectful function to each element of a structure and combines the resulting effects into one effect containing the transformed structure.
Functional Programming in Scala, Second Edition
A traversable functor is an abstraction that systematically applies an effectful function to the elements of a data structure and combines the resulting effects.
- How it is used
- Combines effectful element transformations while preserving the surrounding collection shape.
- How deep it goes
- Derives List implementations with foldRight and map2, then generalizes them to Traverse, State, fusion, nesting, and monad composition.
- Examples
- Uses parsing strings with Option, Either validation, candy-machine State actions, element numbering, and List, Option, Tree, and Map instances.
- What you can do after
- Build it from scratch for List, Option, Either, and State, then generalize it as a Traverse instance.
Read how Functional Programming in Scala, Second Edition explains traverse →
Functional Programming in C#, Second Edition
A traversal operation that uses applicative composition to combine effects from applying a function to each item.
- How it is used
- Combines effectful results across a structure or reverses the order of nested effects.
- How deep it goes
- Derives an Aggregate-based implementation and contrasts monadic and applicative reducers, including a single-value traversal.
- Examples
- Uses comma-separated number parsing, multiple validators for a country code, and airline fare searches.
- What you can do after
- Build it from scratch using Aggregate and apply it to validation and asynchronous searches.
Read how Functional Programming in C#, Second Edition explains traverse →
Also covered in
What to know first
- listA list is an ordered collection of elements arranged in a sequence.
- applicative functorAn 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.
- identity functionAn identity function maps every input to itself unchanged.
- monadA monad is a programming abstraction that provides operations for sequencing computations while encapsulating and preserving their computational context.
Related concepts
- identity functionused by · An identity function maps every input to itself unchanged.
- mapcontrasts with · Map is an operation that applies a function to values in a collection or computational context and returns the results while preserving the structure or context.
- type-lifting functionuses · A type-lifting function embeds a value into a corresponding computational context, container, or type, often a monadic type.
- applicative functoruses · 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.
- applicative styleuses · Applicative style is a functional programming technique for combining independent computations through an applicative interface.
Questions about traverse
What is traverse?
traverse is an operation that applies an effectful function to each element of a structure and combines the resulting effects into one effect containing the transformed structure.
Which Manning books explain traverse?
Functional Programming in Scala, Second Edition and Functional Programming in C#, Second Edition.
What should I know before learning traverse?
Manning books that teach traverse usually introduce list, applicative functor, identity function and monad first.
What is the difference between traverse and map?
traverse is an operation that applies an effectful function to each element of a structure and combines the resulting effects into one effect containing the transformed structure. Map is an operation that applies a function to values in a collection or computational context and returns the results while preserving the structure or 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.

