Skip to content

Simplify replaceAll and splitAll in Hakyll.Core.Util.String #1069

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

Merged
merged 2 commits into from
Apr 7, 2025

Conversation

thomie
Copy link
Contributor

@thomie thomie commented Mar 31, 2025

(=~~) is polymorphic in its return type. Get first match + before/after directly, instead of splitting manually on match indices. Moreover, since =~~ uses 'fail' on lack of match, and Maybe is an instance of MonadFail, listToMaybe isn't necessary.

`(=~~)` is polymorphic in its return type. Get first match + before/after
directly, instead of splitting manually on match indices. Moreover, since
`=~~` uses `'fail'` on lack of match, and `Maybe` is an instance of
`MonadFail`, `listToMaybe` isn't necessary.
@LaurentRDC
Copy link
Collaborator

Thank you for your contribution!

While we're touching these functions, would you mind adding a few test cases here?

Prevent infinite loop when pattern is `.*`.
@thomie
Copy link
Contributor Author

thomie commented Apr 6, 2025

Here you go. Even found a bug!

@LaurentRDC LaurentRDC merged commit b98f903 into jaspervdj:master Apr 7, 2025
27 checks passed
@LaurentRDC
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants