Merged
Conversation
chshersh
suggested changes
Aug 14, 2020
Contributor
chshersh
left a comment
There was a problem hiding this comment.
Nice start! I have a few suggestions on how to improve the code and documentation, but overall a good addition 👍
src/Relude/List.hs
Outdated
| ([2,4,6,8,10],[1,3,5,7,9]) | ||
| -} | ||
| partitionWith :: (a -> Either b c) -> [a] -> ([b], [c]) | ||
| partitionWith = (partitionEithers .) . map |
Contributor
There was a problem hiding this comment.
Let's write slightly more pointful implementation. It will be more readable and maintainable in long-term.
Suggested change
| partitionWith = (partitionEithers .) . map | |
| partitionWith f = partitionEithers . map f |
src/Relude/List.hs
Outdated
| :} | ||
|
|
||
| >>> partitionWith foo [1 .. 10] | ||
| ([2,4,6,8,10],[1,3,5,7,9]) |
Contributor
There was a problem hiding this comment.
Let's add @since annotation to new function, since we already planned the milestone for the new version.
Suggested change
| ([2,4,6,8,10],[1,3,5,7,9]) | |
| ([2,4,6,8,10],[1,3,5,7,9]) | |
| @since 0.8.0.0 |
src/Relude/List.hs
Outdated
Comment on lines
+68
to
+70
| foo x | ||
| | even x = Left x | ||
| | otherwise = Right x |
Contributor
There was a problem hiding this comment.
Let's change example a little bit. To understand better, why partitionEithers might be useful, it's better to give an example where return types are different. For example, I propose to implement the following function:
divideEvenOrShow :: Int -> Either Int String
divideEvenOrShow n
| even n = Left $ n `div` 2
| otherwise = Right $ "Odd: " <> show n
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.
Resolves #319
Checklist:
HLint
hlint.dhallaccordingly to my changes (add new rules for the new imports, remove old ones, when they are outdated, etc.)..hlint.yamlfile (see this instructions).General
stylish-haskellfile.[ci skip]text to the docs-only related commit's name.