A numbered line pairs a text line with an optional line number. The number is optional because some lines may be displayed without numbering, while the text remains part of the value. section 4.1.1
In Haskell, represent one numbered line as (Maybe Int, String), and represent a sequence as a list of those pairs. Maybe encodes the difference between a numbered line and an intentionally unnumbered line. section 4.1.1
Numbering behavior separates two decisions:
- Predicates make policies such as numbering all lines, skipping empty lines, or counting and numbering different sets configurable. section 4.1.1
Mixed numbering
A value such as [(Just 1, "First line"), (Nothing, ""), (Just 2, "Second line")] preserves the empty line while indicating that it should receive no printed number.
