Either
Either is a parameterized sum type whose values hold one of two alternatives, often used to represent an error or a successful result.
Clean Applications with Hexagonal Architecture
Either is a functional data type representing one of two alternatives, commonly a failure value or a successful result.
- How it is used
- Makes expected use case failures explicit as typed outcomes across hexagonal architecture boundaries.
- How deep it goes
- Explains signatures, flatMap short-circuiting, validation conversion, boundary mapping, and failure testing without detailing Either's implementation internals.
- Examples
- Uses article publishing and creation handlers, HTTP error responses, and a repository persistence-failure test.
- What you can do after
- Apply it via Vavr to compose typed use case outcomes, convert validation results, and test error propagation.
Read how Clean Applications with Hexagonal Architecture explains Either →
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 C#, Second Edition
Either is a sum type whose values hold one of two alternatives, commonly representing a success value or an error.
- How it is used
- Models fallible operations and chains their results while preserving error details.
- How deep it goes
- Defines Either and explains Match, Map, Bind, and ForEach, including why a predicate cannot supply a Left value for Where.
- Examples
- Uses result rendering, recruitment rejection, meal preparation, and transfer validation to illustrate outcomes and failure propagation.
- What you can do after
- Apply it via LaYumba.Functional to handle outcomes and compose operations that may fail.
Read how Functional Programming in C#, Second Edition 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.
Also covered in
What to know first
- exceptionAn exception is a runtime signal or value representing an abnormal condition that interrupts ordinary program flow and can be handled or propagated.
- RightRight is the right-hand constructor of an Either type, representing its second alternative and conventionally carrying a successful result.
- data transfer objectA data transfer object is a data-carrying structure that conveys selected information between software components or across boundaries without encapsulating substantial domain behavior.
- functional programmingFunctional programming is a programming paradigm that expresses computation through the evaluation and composition of functions, typically favoring immutable data and minimizing mutable state and side effects.
Related concepts
- exceptioncontrasts with · An exception is a runtime signal or value representing an abnormal condition that interrupts ordinary program flow and can be handled or propagated.
- 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.
- factoryproduced by · A factory is a function, method, or component that creates and returns values or objects while encapsulating construction or selection logic.
- Validatedalternative to · Validated is an error-handling data type that represents successful or failed computations and can accumulate errors across combined failures.
- validatorused by · A person, component, function, or rule that checks whether an input, state, or system meets specified criteria.
Questions about Either
What is Either?
Either is a parameterized sum type whose values hold one of two alternatives, often used to represent an error or a successful result.
Which Manning books explain Either?
Clean Applications with Hexagonal Architecture, Functional Programming in JavaScript, Learn Haskell by Example, Functional Programming in C#, Second Edition, Functional Programming in Scala, Second Edition and Write Powerful Rust Macros.
What should I know before learning Either?
Manning books that teach Either usually introduce exception, Right, data transfer object and functional programming first.
What is the difference between Either and exception?
Either is a parameterized sum type whose values hold one of two alternatives, often used to represent an error or a successful result. An exception is a runtime signal or value representing an abnormal condition that interrupts ordinary program flow and can be handled or propagated.
What is Either a kind of?
Either is a kind of algebraic data type. An algebraic data type is a composite type whose values are formed from product structures, finite alternatives, or both through type constructors.
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.





