liveBook · Manning

Fmap

Fmap is an operation that applies a function to values within a functor while preserving the functor’s structure.

How 3 Manning books explain it

Learn Haskell by Example

fmap is the standard Haskell function that applies a function to the contents of a value in a Functor while preserving the surrounding structure.

How it is used
Transforms parsed, command-line, and generated values without discarding their `Either`, `IO`, `Parser`, or generator context.
How deep it goes
Defines the Functor type and kinds, then implements a `Parser` instance through nested `Either` and tuple mappings.
Examples
Demonstrates CSV construction, `String`-to-`Text` command arguments, magic-number parsers, and a proposed `RandomIO` Functor instance.
What you can do after
Apply it via `fmap`, `<$>`, and `<$` to transform successful or produced values while preserving their wrapper.

Read how Learn Haskell by Example explains fmap →

Functional Programming in JavaScript

A mapping operation for a functor that applies a function to the wrapped value and returns a new functor of the same type.

How it is used
Uses functor mapping to transform encapsulated values while preserving their wrapper context.
How deep it goes
Defines fmap, implements it in Wrapper, and demonstrates chained transformations, but does not develop formal functor laws.
Examples
Demonstrates Wrapper values, incrementing 2 to 5, chaining to 15, identity extraction, and logging with tap.
What you can do after
Build it from scratch by implementing Wrapper.fmap and chain transformations without directly accessing the wrapped value.

Read how Functional Programming in JavaScript explains fmap →

Functional Design and Architecture: Examples in Haskell

fmap is the standard functor-mapping operation that applies a function to a functor's contained values while preserving its structure.

How it is used
Uses one abstract operation to transform values across lists, Maybe values, and free-monad structures without changing their shapes.
How deep it goes
Defines Functor behavior, works through list and Maybe examples, and implements fmap for a custom free-monad constructor.
Examples
Uses name-length lists, nested Maybe values, integer transformations, and SandwichConstructor continuations.
What you can do after
Apply transformations with fmap while preserving list, Maybe, or custom Functor structure.

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

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.