Composition
Composition is a technique for combining simpler functions, components, or operations into a larger structure or behavior.
The Joy of JavaScript
A pipeline is a composition pattern where output from one stage becomes input to the next stage in sequence.
- How it is used
- Assembles small JavaScript functions into declarative business logic, including file word counts, hashing, and balance calculations.
- How deep it goes
- Defines execution order, implements compose2 and compose, and works through refactoring, currying, side effects, and point-free chains.
- Examples
- Uses string and file word counts, transaction hashing, and blockchain balance calculations as composed workflows.
- What you can do after
- Build it from scratch with compose2 and compose, then apply it to assemble reusable functions and separate pure transformations from file reading.
Functional Programming in JavaScript
A sequence of function invocations linked by a shared intermediate value or by staged transformation.
- How it is used
- Builds modular JavaScript programs by joining small transformations into reusable operations.
- How deep it goes
- Explains compatibility, manual pipelines, compose implementation, and Ramda composition, while deferring static type systems.
- Examples
- Uses SSN cleanup and validation, word counting, student display, grade ranking, and Unix-style data processing.
- What you can do after
- Build it from scratch by composing compatible JavaScript functions with compose or Ramda's R.compose and R.pipe.
Read how Functional Programming in JavaScript explains composition →
Functional Programming in Scala, Second Edition
Kleisli composition is an operation that composes functions producing monadic results into a larger monadic computation.
- How it is used
- Assembles independent functions and stream transformations into reusable higher-level computations.
- How deep it goes
- Defines ordinary composition by types and implementation, then derives Kleisli composition as a view of monadic associativity.
- Examples
- Uses trigonometric functions, Option cases, and composed nonempty and lowercase stream pipes.
- What you can do after
- Build it from scratch by implementing ordinary and Kleisli compose, then combine stream transformations.
Read how Functional Programming in Scala, Second Edition explains composition →
Kubernetes for Developers
Object composition in Kubernetes is a pattern in which a higher-order resource embeds the specification of a lower-level resource.
- How it is used
- Uses embedded specifications to configure Pods managed by Deployments and Jobs, and Jobs scheduled by CronJobs.
- How deep it goes
- Explains template nesting through runnable manifests and controller behavior, while directing readers to API documentation for additional embedded fields.
- Examples
- Shows a standalone Pod, a one-off Job running a container command, and a CronJob scheduling that Job.
- What you can do after
- Build it from scratch by placing a PodSpec in a managed template and locating each setting at its proper nesting level.
Write Powerful Rust Macros
Function composition combines functions so that the output of one becomes the input of another.
- How it is used
- Builds larger Rust behavior by chaining small functions through declarative or function-like macros.
- How deep it goes
- Works from typed two-function composition through recursive macro expansion and procedural parsing, without detailing the complete parser implementation.
- Examples
- Uses `add_one`, `stringify`, and `prefix_with` in comma-, arrow-, and dot-separated composition pipelines.
- What you can do after
- Build it from scratch with a generic `compose_two` closure and a recursive macro, or apply it through generated dot syntax.
The Art of Code
Function composition is the construction of a function by chaining functions so that one function's output becomes the next function's input.
- How it is used
- Uses composition to express functional-programming behavior as reusable transformations and readable data flows.
- How deep it goes
- Explains single-responsibility decomposition, chaining, language support, and tradeoffs, but stops short of formal composition theory.
- Examples
- Uses string sanitization and book-title extraction, sorting, and collection to illustrate composed transformations.
- What you can do after
- Build it from scratch by splitting multi-step behavior into reusable functions and composing them into readable transformations.
Go by Example
Composition is a design approach that builds larger abstractions by combining smaller components rather than inheriting implementation from a base type.
- How it is used
- Builds reusable HTTP middleware, handlers, logging layers, and package APIs from focused pieces.
- How deep it goes
- Explains embedding, wrappers, higher-order functions, interfaces, assertions, and Context; defers detailed embedding treatment.
- Examples
- Uses response-recording and logging middleware around an HTTP health handler, with request logs and handler-chain flow.
- What you can do after
- Apply it via Go handlers and interfaces to extend behavior without modifying existing implementations.
F# in Action: A Revised Edition of Get Programming with F#
Function composition is the operation of combining functions so that the output of one function becomes the input of another.
- How it is used
- Builds reusable behaviors by joining small transformations or HTTP handlers into larger workflows.
- How deep it goes
- Defines `>>`, contrasts it with pipelines, and treats composition as shorthand rather than explaining implementation internals.
- Examples
- Uses number transformations, an email workflow, a gas-state exercise, and a GET `/device/status` handler.
- What you can do after
- Apply it via F# and Giraffe to chain transformations or HTTP handlers into readable workflows.
Read how F# in Action: A Revised Edition of Get Programming with F# explains composition →
Grokking Data Structures
Composition is a design technique that builds an object from instances of other objects rather than deriving it through inheritance.
- How it is used
- Uses composition to encapsulate reusable data-structure implementations behind focused class interfaces.
- How deep it goes
- Defines composition, shows constructors and delegated methods, and stops short of a detailed comparison of composition and inheritance.
- Examples
- Uses UnsortedArray wrapping Array and Bag delegating insertion and traversal to SinglyLinkedList.
- What you can do after
- Build it from scratch by wrapping an existing data structure and forwarding only the operations a new class should expose.
Learn Haskell by Example
Function composition is the construction of a function whose result is obtained by applying one function to the result of another.
- How it is used
- Uses composition to assemble concise CSV transformations and file-writing actions from partially applied functions.
- How deep it goes
- Defines operator order, demonstrates chaining and folding, and stops short of formal mathematical treatment.
- Examples
- Demonstrates arithmetic composition, CSV serialization, composed functions in lists, and folding composition across a function list.
- What you can do after
- Apply Haskell composition to construct compact transformation pipelines and CSV file writers.
Deep Learning with PyTorch, Second Edition
The operation of applying one function to the output of another, used here to describe how layers are chained in a neural network.
- How it is used
- Explains how neural network layers are chained, with each layer’s output serving as the next layer’s input.
- How deep it goes
- Defines composition through sequential layer outputs and notes that matrix weights calculate across a layer.
- Examples
- Uses equations that pass each layer’s calculated output into the following layer.
- What you can do after
- Understand how outputs from successive neural network layers combine to produce a final output.
Read how Deep Learning with PyTorch, Second Edition explains composition →
Related concepts
- inheritancecontrasts with · Inheritance is a mechanism by which a child type or element receives properties, values, or behavior from a parent, subject to system rules and possible overrides.
- translationuses · A translation is a geometric transformation that moves every point by the same displacement without changing an object’s shape or orientation.
- rotationuses · A rotation is a geometric transformation that turns points or objects about a fixed center, origin, or axis through an angle while preserving distances and angles.
- functionuses · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
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.










