A closed context encloses computation so its internal control flow and effects remain behind an abstraction boundary. Operations interact with the context through defined transformations rather than managing every failure or state transition themselves. section 5.0 section 8.2.2
Validation uses this boundary to contain checking logic. Instead of inserting validation before every composed function or repeating try/catch blocks, a chain carries successful computation forward while recording failure and stopping subsequent operations. section 5.0
Promises apply the same idea to time. A Promise begins pending or fulfilled, changes according to executor or reaction outcomes, and lets then compose work without exposing its asynchronous control flow. Rejected computation can fall through the chain to catch. section 8.2.2
The pattern matters because it:
- Separates application operations from validation or asynchronous control flow. section 8.2.2 section 5.0
- Supports declarative composition through operations analogous to map, of, and flatMap. section 8.2.2 section 5.0
- Keeps success and failure behavior within one composable structure rather than scattering handlers across functions. section 8.2.2 section 5.0
A validation pipeline
Validation.of(block) .flatMap(checkLength(64)) .flatMap(checkTampering) .flatMap(checkDifficulty) .flatMap(checkLinkage(previousHash)) .flatMap(checkTimestamps(previousTimestamp)); Each check operates inside the Validation context. The pipeline expresses the order of checks while the context manages whether later computations continue. section 5.0
const p = new Promise(resolve => {
setTimeout(() => {
resolve('Done');
}, 3000);
});
console.log(p); // Promise { <pending> }
A pending Promise makes the hidden time boundary visible: the object exists immediately while its computation completes later. section 8.2.2
