-
Notifications
You must be signed in to change notification settings - Fork 273
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
Add toAlternativeOf
?
#1031
Comments
The main consideration is that toAlternativeOf :: Alternative f => Getting (Alt f a) s a -> s -> f a should be weakened to toAlternativeOf :: Applicative f => Getting (Alt f a) s a -> s -> f a then it will only require an |
Thanks for the feedback. I'll prepare a PR. Meanwhile, I'm conflicted about the name Possibilities:
Honestly I like |
I admit I'm not a big fan of lots of camelCase. I'd probably go |
derp. this is |
I think it's |
Yeah. I guess "Also supporting a weaker constraint for single target optics" is generally a thing, |
Right, whereas |
I use this function without issues:
https://github.com/sjshuck/hs-pcre2/blob/2d01498056569905abc643fdffa697efbbd6c08c/src/hs/Text/Regex/Pcre2/Internal.hs#L130-L132
I use it as a simple way to unify "find-all" (
f ~ []
) and "find-one" (f ~ Maybe
) in a single implementation. It will attempt to fill up theAlternative
or run out of targets, whichever comes first. But I don't have much insight into performance implications. Maybe there's some kind ofEndo
-based implementation that's possible and preferable (à latoListOf
?Any other considerations?
The text was updated successfully, but these errors were encountered: