liveBook · Manning

Programmable commas

As explained in Functional Programming in JavaScript

A style of composing computations so that the sequencing semantics are governed by a monad rather than by explicit separators or control flow.

Programmable commas describe composing steps so a monad controls sequencing and failure handling instead of manual separators, nested checks, or thrown errors. section 5.4

The pattern turns a student lookup flow into a safe pipeline: clean input, validate it, fetch a record, format fields, and append output while invalid or missing data is skipped.

The composition is built with these monadic steps:

  • use chain for validation and lookup steps that return monads. section 5.4

Imperative form and monadic rewrite

A direct version uses nested null checks and throws for invalid input or missing students. The monadic rewrite replaces that control flow with a composed pipeline that returns Either.Right on success or an error message on failure.

How Functional Programming in JavaScript covers it

How deep it goes
Explains the pipeline pattern through small refactors and a complete composed example, but stops short of monad theory.
Examples
Uses student lookup, SSN validation, CSV formatting, HTML appending, and trace logging.
What it assumes
Assumes basic JavaScript functions and arrays, then introduces monads, chain, and map from the example.
What you can do after
Build it from scratch as a fault-tolerant composition that skips invalid branches and formats successful results.
How it connects
Links monads with chain, map, compose, Maybe, Either, IO, and tap.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in JavaScript. The section links point to the parts of the book it draws on.