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

foldl1 for NonEmpty #61

Closed
andrewthad opened this issue Dec 18, 2015 · 6 comments
Closed

foldl1 for NonEmpty #61

andrewthad opened this issue Dec 18, 2015 · 6 comments

Comments

@andrewthad
Copy link

I think that it would be good to add foldl1 to NonEmpty, especially because we can actually write a safe version of it:

nonEmptyFoldl1 :: (a -> a -> a) -> NonEmpty a -> a
nonEmptyFoldl1 g (a :| as) = List.foldl g a as

The same can be done for foldr1. Although at this point in time, it may make more sense to add this to base-4.9 instead of semigroups.

@andrewthad
Copy link
Author

Also, having append would be nice.

@tomjaguarpaw
Copy link

+1 I've just noticed that append is missing, too.

@RyanGlScott
Copy link
Collaborator

Are Data.Foldable.{foldl1,foldr1} and Data.Semigroup.<> not sufficient?

@tomjaguarpaw
Copy link

I thought there'd be a catch! Yes, they're sufficient but should be documented as such. Having no reference to "append" in the Haddock is somewhat disconcerting.

@RyanGlScott
Copy link
Collaborator

That sounds reasonable. But since Data.List.NonEmpty is in base now, make sure any changes to its documentation also get merged into base as well.

@ekmett
Copy link
Owner

ekmett commented Aug 29, 2016

Any changes here will be made to simply track base. As a result if you want such a function I recommend you file it as a proposal to libraries@haskell.org, so we can get it into base. Any changes made to base will be mirrored here for older GHC versions.

@ekmett ekmett closed this as completed Aug 29, 2016
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

4 participants