liveBook · Manning

Either

Either is a sum type representing one of two alternatives, conventionally called Left and Right and often used for failure and success outcomes.

How 4 Manning books explain it

Functional Programming in JavaScript

A monadic type that represents a value that can be one of two possibilities, commonly used to encode success or error outcomes.

How it is used
Carries success or failure through function chains without throwing exceptions.
How deep it goes
Defines Left and Right behavior, then shows wrapping, mapping, fallback, and exception capture.
Examples
Uses database lookup, student retrieval, URL decoding, and error logging examples.
What you can do after
Apply Either to return one value for success or failure, then recover, log, or keep composing safely.

Read how Functional Programming in JavaScript explains Either →

Learn Haskell by Example

Either is a parameterized Haskell type representing a value with one of two alternatives, conventionally an error value or a successful result.

How it is used
Encodes validation, parsing, and selected IO failures as values that preserve an error message or exception.
How deep it goes
Defines Left and Right, applies them in smart constructors and parsers, and demonstrates elimination with either and mapping with fmap.
Examples
Demonstrates CSV size checks, PNM magic-number parsing, fixed-string parsers, and safe filesystem listing.
What you can do after
Apply it via Data.Either and Control.Exception to return recoverable errors instead of silently failing or crashing.

Read how Learn Haskell by Example explains Either →

Functional Programming in Scala, Second Edition

The Either monad is the monadic structure formed by sequencing computations that may produce a left or right result.

How it is used
Models recoverable failures as typed values while sequencing computations that may succeed or fail.
How deep it goes
Defines constructors, implements core combinators, and applies them to parsing, validation, sequencing, and traversal.
Examples
Uses empty-list means, safe division, exception capture, insurance-quote parsing, and Name-Age-Person validation.
What you can do after
Builds composable error-handling functions with map, flatMap, map2, sequence, traverse, and for-comprehensions.

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

Write Powerful Rust Macros

Either is a sum-type pattern representing one of two alternatives, conventionally a successful result or a failure.

How it is used
Frames error handling as an explicit value that is either a successful result or a failure.
How deep it goes
Defines a generic enum and demonstrates matching plus mapping, connecting the representation to practical handling.
Examples
Uses a calculate_answer_to_life function returning Success(42), a match expression, and a map transforming one into two.
What you can do after
Build it from scratch by defining Either, returning it from functions, matching its variants, and mapping successful values.

Read how Write Powerful Rust Macros explains Either →

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.