print $ match @[] "\\d+" "123 456"
-- prints: ["123","456"]
-- should print: ["123"]
This is because Text.Regex.Pcre2.Internal.toAlternativeOf "fills up" the Alternative container.
Short term, deliberately limit the functions to a single match to make the behavior match the docs.
Long term, observe this:
currentBuggyMatch = matchAll
Embrace this accidental behavior and remove matchAll and friends. If the intended match per current docs is really needed—to produce a list that is at most a singleton—it can be recovered by
take 1 . currentBuggyMatchWeShouldEmbrace patt
maybeToList . currentBuggyMatchWeShouldEmbrace patt
This is because
Text.Regex.Pcre2.Internal.toAlternativeOf
"fills up" the Alternative container.Short term, deliberately limit the functions to a single match to make the behavior match the docs.
Long term, observe this:
Embrace this accidental behavior and remove
matchAll
and friends. If the intendedmatch
per current docs is really needed—to produce a list that is at most a singleton—it can be recovered by