-
Notifications
You must be signed in to change notification settings - Fork 67
Added split operations to IsSequence, EqSequence #80
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
Conversation
@@ -411,6 +410,12 @@ class (Monoid seq, MonoTraversable seq, SemiSequence seq, MonoPointed seq) => Is | |||
unsafeIndex :: seq -> Index seq -> Element seq | |||
unsafeIndex = indexEx | |||
|
|||
|
|||
-- | 'splitWhen' splits a sequence into components delimited by separators, where the | |||
-- predicate returns True for a separator element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a comment about whether the separators are retained or discarded? A concrete example would be useful. At least I personally get confused about this whenever I use split-style functions.
In addition to the documentation comments, would you be able to add a test case for this, to codify the semantics? |
I'll add following (from ByteString docs):
And will work on test case as well |
I find the naming of these unintuitive (even if it may be consistent with some of the underlying libraries). I think |
IIRC the different splitting operators have slightly different edge case behavior (IIRC it was how they handle being given an empty string as the separator, or how splitting on a string consisting of just the separator works). I don't remember for sure but it might be worth double checking. |
Considering the naming, I think the most intuitive short name for To summarize:
|
@w3rs I agree with your explanation. Do you use classy-prelude? One option is to re-export |
@gregwebs yes, it makes sense.
This name is actually already taken with this purpose:
|
I am favoring |
Rename `split` to `splitElem`, `splitOn` to `splitSeq`. Split functions now follow `Data.List.Split` rules for edge cases. These rules are also encoded in test cases.
I pushed the new commit with improvements. It also has new |
Looking good! If you want a shorter name, you could use |
@gregwebs I think I can bear a couple extra chars after all. |
Looks good to me, I'm happy to merge thanks for all the improvements. Can you both confirm that this is ready to go? |
@snoyberg since we couldn't find much better names than |
-- | ||
-- 'splitElem' can be considered a special case of 'splitSeq' | ||
-- | ||
-- > 'splitSeq' (singleton sep) === 'splitElem sep' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot use ''
with >
. It produces invalid documentation. You must wrap the statement like:
@
'splitSeq' (singleton sep) === 'splitElem' sep
@
@kbillings good catch! I had no success with |
thanks a lot! |
Added split operations to IsSequence, EqSequence
No description provided.