liveBook · Manning

Functor

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

How 6 Manning books explain it

The Joy of JavaScript

A functor is a structure or abstraction that provides a mapping operation over contained values while preserving the surrounding structure.

How it is used
Uses map to compose transformations over contained values, including validation flows that skip work after failure.
How deep it goes
Defines map through identity and composition rules, then implements a reusable mixin; defers extensive algebraic theory.
Examples
Demonstrates array mapping, an Id transformation pipeline, and Success/Failure branches that run or skip mapped functions.
What you can do after
Build it from scratch with an Id-style container and map mixin, then apply the contract to conditional validation.

Read how The Joy of JavaScript explains functor →

Learn Haskell by Example

Functor is the Haskell type class for types whose parameterized values support structure-preserving mapping over their contents.

How it is used
Uses fmap to transform values inside CSV results, IO actions, parsers, and random generators without discarding their contexts.
How deep it goes
Defines Functor through fmap and kinds, then implements a Parser instance; functor laws are not detailed.
Examples
Demonstrates CSV Either mapping, command-line IO [String] conversion, Parser MagicNumber construction, and a RandomIO Functor exercise.
What you can do after
Apply it via fmap, <$> and <$ to change contained results while preserving list, Maybe, Either, IO, or Parser structure.

Read how Learn Haskell by Example explains functor →

Functional Programming in Scala, Second Edition

A functor is an abstraction that provides a map operation for transforming values inside a computational structure while preserving that structure.

How it is used
Generalizes map across type constructors to factor duplicated transformations into reusable combinators.
How deep it goes
Defines the Scala interface, derives distribute and codistribute, and justifies identity and composition laws through structural preservation.
Examples
Uses List, Option, Gen, Parser, Par, generic unzip, and codistribute to demonstrate map’s shared shape.
What you can do after
Apply it to derive structure-preserving transformations and generic combinators from map alone.

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

Functional Design and Architecture: Examples in Haskell

A functor is an abstraction that supports mapping a function over a value while preserving the structure of its context.

How it is used
Generalizes structure-preserving mapping into reusable functional operations for lists, optional values, and domain models.
How deep it goes
Defines fmap, demonstrates lists and nested Maybe values, and constructs a custom instance for a domain-specific algebraic type.
Examples
Uses name-length lists, nested Maybe values, integer-to-string mapping, and a SandwichConstructor continuation instance.
What you can do after
Build a Functor instance for a parameterized type and apply fmap across ordinary, nested, and domain-specific structures.

Read how Functional Design and Architecture: Examples in Haskell explains functor →

Functional Programming in JavaScript

An abstract container or computational context that supports mapping a function over its contents while preserving its structure.

How it is used
Uses containers to transform values while reducing scattered null checks and caller-managed error-handling complexity.
How deep it goes
Explains fmap operationally and demonstrates immutable chaining, while deliberately stopping short of category theory.
Examples
Demonstrates Wrapper, arithmetic with plus3, identity extraction, logging, chained fmap calls, and Array map and filter signatures.
What you can do after
Build it from scratch with a Wrapper class, wrap values, map transformations, and chain immutable computations.

Read how Functional Programming in JavaScript explains functor →

Fabulous Adventures in Data Structures and Algorithms

A functor is a mapping between categories that preserves their objects, morphisms, and composition.

How it is used
Uses composable abstractions to connect category theory with programming-language design and generic interfaces.
How deep it goes
Defines categories, morphisms, variance, and endofunctors, then stops short of deeper category-theoretic development.
Examples
Uses a three-object category, a C# integer-to-string function, and a diagram of dashed mapping arrows.
What you can do after
Evaluate type relationships and generic interfaces using covariance, contravariance, and preserved morphisms.

Read how Fabulous Adventures in Data Structures and Algorithms explains functor →

Related concepts

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.