elm-community / list-extra

Convenience functions for working with List.
http://package.elm-lang.org/packages/elm-community/list-extra/latest
MIT License
135 stars 59 forks source link

Remove one of two functions with same implementation, generally make consistent names #7

Closed jvoigtlaender closed 8 years ago

jvoigtlaender commented 8 years ago

deleteIf and removeWhen are the same function. I think the library should contain only one of them.

jvoigtlaender commented 8 years ago

Also, there's "removeAt", which might as well be called "deleteAt". The library could use a pass of making names consistent.

jvoigtlaender commented 8 years ago

The last comment, because there are also a bunch of "drop..." functions. What is the difference between deleting, removing, and dropping?

shmookey commented 8 years ago

Edit: now that this issue is closed, I've cleaned up the following list to make it easier to refer back to.

If the goal is to go for consistent naming, then to me:

My deleteFirst (https://github.com/elm-community/list-extra/pull/6) operates on the first matching element, but that's just copying a Haskell convention. To my ear "delete" connotes erasing data from persistent storage, rather than merely discarding it from a data structure in memory. I'd prefer to clean up the other names and rename it to remove.

I would suggest:

jvoigtlaender commented 8 years ago

What about the function currently called dropDuplicates?

And I assume there would be renaming of current dropWhileEnd to dropWhileRight, and analogously for takeWhileEnd?

shmookey commented 8 years ago

I think that makes sense. Re: dropDuplicates, I'm inclined to think of it in terms of what you get back - how about uniques?

Happy to put these changes in my PR.

mgold commented 8 years ago

In my nonempty list library, I offer uniq and dedup. The former removes all duplicates, while the latter removes adjacent duplicates. I'm not thrilled with the abbreviations, but maybe unique, as a verb, rather than the plural noun?

shmookey commented 8 years ago

Yeah, sounds good. Updated #6.

jvoigtlaender commented 8 years ago

Some context about dropDuplicates/unique: https://github.com/elm-community/elm-list-extra/issues/31.

Also, a change here affects https://github.com/elm-community/list-extra/pull/5, so bring this name change up there as well?