An abstract data type (ADT) defines a value through its behavior and supported operations rather than exposing its concrete representation. In functional JavaScript, an ADT can provide a context—such as success or validation state—while operations transform the contained value without requiring callers to manage that context directly. section 5.1 section 5.6
The practical payoff is composability. Extracted operations such as map can transform an ADT fluently, while flatMap sequences operations that may preserve or change the surrounding context. For example, safe division chains validation for non-NaN and nonzero values before performing the division. section 5.6
A context-preserving computation
Success.of(2)::map(x => x * 2)::map(x => x ** 2) produces Success(16). The individual functions operate on the contained number, while the Success context remains part of the result. section 5.6
const { flatMap } = Monad;
const safeDivideBy = denominator => numerator =>
Success.of(numerator)
:: flatMap(notNaN)
:: flatMap(notZero)
:: map(divideBy(denominator));
const halve = safeDivideBy(2);
halve(16); // Success(8)
Shows an ADT-oriented safe division pipeline that combines flatMap validation with map for the final transformation. section 5.6



