Skip to content

Don't start a new word at chunk boundaries in lazy toTitle - #722

Merged
Lysxia merged 2 commits into
haskell:masterfrom
swinilohani616-dot:fix-lazy-totitle
Nov 19, 2026
Merged

Lysxia merged 2 commits into
haskell:masterfrom
swinilohani616-dot:fix-lazy-totitle

Conversation

@swinilohani616-dot

Copy link
Copy Markdown
Contributor

Lazy toTitle ran the strict toTitle on every chunk separately, and the strict version treats the start of its input as the start of a word. So whenever a chunk boundary fell inside a word, the letter after it was capitalised: toTitle (fromChunks ["hel", "lo wor", "ld"]) gave "HelLo WorLd".

Make the strict implementation take and return whether it is in the middle of a word, and have lazy toTitle carry that from one chunk to the next. Strict toTitle starts outside a word as before, so its behaviour is unchanged. Add a property that lazy toTitle agrees with strict toTitle regardless of chunking, plus the example above.

Fixes #721

Lazy toTitle ran the strict toTitle on every chunk separately, and the
strict version treats the start of its input as the start of a word.
So whenever a chunk boundary fell inside a word, the letter after it
was capitalised: toTitle (fromChunks ["hel", "lo wor", "ld"]) gave
"HelLo WorLd".

Make the strict implementation take and return whether it is in the
middle of a word, and have lazy toTitle carry that from one chunk to the
next. Strict toTitle starts outside a word as before, so its behaviour
is unchanged. Add a property that lazy toTitle agrees with strict
toTitle regardless of chunking, plus the example above.

Fixes haskell#721
@Lysxia
Lysxia merged commit 9ae1442 into haskell:master Nov 19, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lazy toTitle capitalises letters at chunk boundaries

2 participants