-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iron out API discrepancies #289
Comments
I agree that it would be nice if these APIs were more consistent.
|
Missing for lazy bytestrings:
Missing both for strict and lazy bytestrings:
|
I think users could simply use For an earlier attempt at a lazy |
Good idea. In this case it boils down to defining an efficient |
I would like to dibs this. (Together with all the subordinate issues.) It looks like a bunch of fun little exercises, and I think I am able to prototype all of them easily. Then there is the low level optimization part, and at that I may need some advice. Would this sort of help be wanted? My first goal would be to make a draft pull request with all functions doing roughly the right thing, so that we may discuss small discrepancies in behaviour to death and codify the final behaviour in automated checks. |
|
Yeah, let's address that discrepancy too. I think we can use a counting sort where we make a single pass over the input to determine the total length and the number of occurrences for each byte. Then we simply write out the bytes. Take a look at the strict |
Alright, I added |
@kindaro My recommendation would be to split this work across multiple PRs. If you do it all in a single PR, it will be harder to review and you're more likely to run into merge conflicts. |
Can you explain why it will be easier to review multiple small pull requests? Either way there is the same amount of code. But with smaller pull requests more bureaucracy is added. What is the gain? |
I simply find large diffs harder to understand and navigate. For example, the question "What tests do we have for addition x?" is IMHO easier to figure out in a small diff. |
This makes sense. But by this logic I should add functions one by one. This would result in there being a dozen of tiny pull requests. It would be hard to manage.
So I think we should find a cheaper way to answer this question. In most cases you can replace a function by an I agree that |
I narrowed the scope of #364 to folds and scans. |
Missing for lazy bytestrings:
unfoldrN
(see also Benchmark unfoldrN and inline createAndTrim' #128)isInfixOf
,breakSubstring
(see Lazy variants of isInfixOf and breakSubstring #30 and Search algorithms #307)foldr'
andfoldr1'
(not that strict folds make tremendously much sense for lazy structures, but we already havefoldl'
andfoldl1'
in place) (see Straighten folds and scans. #373)scanl1
,scanr
andscanr1
(see Straighten folds and scans. #373)takeEnd
,dropEnd
,takeWhileEnd
,dropWhileEnd
,spanEnd
andbreakEnd
(see Lazy dropEnd and friends #306).Missing both for strict and lazy bytestrings:
replace :: ByteString -> ByteString -> ByteString -> ByteString
(lazy variant would requirebreakSubstring
or similar first, so see Search algorithms #307)splitOn :: ByteString -> ByteString -> [ByteString]
(see splitOn for Data.ByteString/Data.ByteString.Lazy #100)There are minor but annoying differences between API provided byData.ByteString
,Data.ByteString.Char8
,Data.ByteString.Lazy
,Data.ByteString.Lazy.Char8
. Plus we are missing certain encoding-agnostic functions available forText
, such ascompareLength
,replace
,splitOn
, etc.A good starting point (even if a bit outdated) is https://github.com/haskell-backpack/backpack-str/tree/master/str-sig#feature-matrixThe text was updated successfully, but these errors were encountered: