O'Reilly logo

Learning Java Functional Programming by Richard M Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Monads

A monad structure can be thought of as a chain of operations wrapped around an object. These operations are executed against an object and return some value. In this sense, monads support function composition.

The chaining sequence allows programmers to create pipelines, a sequence of operations, to solve their problems. In addition, monads allow operations against the contained values without having to extract them.

To illustrate the use of monads, we will be using a Part class as defined here:

public class Part { private int partNumber; private String partName; private boolean outOfStock; public Part(int partNumber, String partName) { this.partNumber = partNumber; this.partName = partName; } public boolean isOutOfStock() { return outOfStock; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required