Either
Either is a sum type representing one of two alternatives, conventionally called Left and Right and often used for failure and success outcomes.
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.
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.
Related concepts
- exceptioncontrasts with · An exception is a runtime signal or object representing an abnormal condition that interrupts ordinary program flow and may be handled or propagated.
- Validatedalternative to · Validated is an error-handling data type that represents successful or failed computations and can accumulate errors across combined failures.
- algebraic data typekind of · An algebraic data type is a composite type whose values are formed from product structures, finite alternatives, or both through type constructors.
- Righthas part · Right is the right-hand constructor of an Either value, conventionally representing a successful result and carrying its associated value.
- Lefthas part · Left is the left-hand constructor of an Either value, conventionally representing and carrying failure or error information.
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.



