Repository navigation
Explain the empty components in splitWith's documentation - #728
Open
swinilohani616-dot wants to merge 2 commits into
Open
swinilohani616-dot wants to merge 2 commits into
swinilohani616-dot wants to merge 2 commits into
Conversation
The splitWith example shows empty strings in the result, but the documentation only mentioned the case of two adjacent separators, which left the leading and trailing empty components unexplained. Spell out that n separators give n + 1 components and when a component is empty, and add the laws relating splitWith to split and intercalate, as suggested in the issue. The laws are stated for a predicate of the form (== w), since rejoining can't recover the input when the predicate matches several different separators. Fixes haskell#560
Contributor
|
Sorry, but that's too verbose, especially repeated 5 times across different modules. #560 suggests repeating the law connecting |
As suggested in review, drop the extra explanation and keep just the law connecting splitWith and intercalate, matching how split documents it.
Author
Makes sense, thanks! I've cut it down to just the intercalate law, written the same way split documents it. I kept that one line in each module that has splitWith, since they each have the matching law under split, but I'm happy to keep it to Data.ByteString.Char8 only if you'd prefer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #560.
The
splitWithexample confused people because it's not obvious where the empty strings come from. Assuggested in the issue, this just repeats the
intercalatelaw from thesplitdocs, which makes it clear:split on
c, glue the pieces back together withc, and you get the original string.I added the same line to each module that has
splitWith, worded the waysplitalready has it.