Skip to content
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

fold*1 variants for NonEmpty #240

Open
twhitehead opened this issue Dec 14, 2021 · 3 comments
Open

fold*1 variants for NonEmpty #240

twhitehead opened this issue Dec 14, 2021 · 3 comments

Comments

@twhitehead
Copy link

Would seem logical if RIO.NonEmpty included the NonEmpty specialized fold*1 variants in addition to scan*1.

Don't know for sure, but I expect they weren't included due to the fact they normally come via Data.Foldable and not Data.List.NonEmpty.

@snoyberg
Copy link
Collaborator

I don't have an inherent objection, but I'd be concerned about exposing partial versions of these functions. In particular, if we expose the fully generalized versions from Foldable we will accidentally expose a partial function when applied to other data structures. I'm not sure what the best way forward is.

@twhitehead
Copy link
Author

Just expose specialized versions would, if nothing else, be consistent with the scan* exports. That is, currently we have

scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b
scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a

so it would seem logical to do

foldl' :: Foldable f => (b -> a -> b) -> b -> f a -> b
foldl1' :: (a -> a -> a) -> NonEmpty a -> a

@snoyberg
Copy link
Collaborator

Sorry I missed the original description. Yes, that seems reasonable, PR welcome.

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

No branches or pull requests

2 participants