Closed Lev135 closed 2 years ago
I think the best thing is probably to update the documentation - it definitely is always non-empty. Changing the type has some advantages, but is also going to break all users, so probably not a good idea now. There is https://github.com/ndmitchell/extra/blob/master/src/Data/List/NonEmpty/Extra.hs, where it might be more reasonable to add with the NonEmpty type.
I think the best thing is probably to update the documentation - it definitely is always non-empty. Changing the type has some advantages, but is also going to break all users, so probably not a good idea now. There is https://github.com/ndmitchell/extra/blob/master/src/Data/List/NonEmpty/Extra.hs, where it might be more reasonable to add with the NonEmpty type.
I think that this function should be in Data.List.Extra
because it doesn't work with NonEmpty
list as one would expect if it were in Data.List.NonEmpty.Extra
. To be more precise, what changes I suggest, I've opened pool request with changed files: https://github.com/ndmitchell/extra/pull/96
As I can see from source code
repeatedly
applizef
only to non empty lists:However, this is not specified in the type and the documentation also says nothing about it. It seems reasonable either to change type to
(NonEmpty a -> (b, [a])) -> [a] -> [b]
or just note this in docs, since not in all cases there is a suitable way to definef
on an empty list.