-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Should NonEmptyList have its own data type? #537
Comments
it will be convenient to define custom methods but what about I recall that @stew wanted to use a separate project for "fancy" data structure |
I'm not necessarily suggesting it, but another possibility would be to define List-like syntax for |
@refried I had thought about that... Doesn't seem like an awful idea. Does anyone have reasons why that's an awful idea? |
@coltfred The main down-side I can think of is that it requires a non-obvious import to get the |
@julien-truffaut I did recently start the https://github.com/stew/dogs project, but I think NonEmptyList is going to end up staying here, because we want to use it in cats itself. |
@stew lol at bird beaks |
@stew could we use |
On a related note I wonder if |
@adelbertc I like this. |
Going back, I think Personally I've only found myself reaching for a non-empty Perhaps we can (somehow) just abstract between Thoughts? |
@adelbertc I think you might be right. I would say that we should not be putting data types in So maybe a good place to start would be trying to add all these types to Dogs and then seeing which seem the most useful in Cats? For example, I'm working on a non-empty linked list which interoperates efficiently with a related possibly-empty linked list type. We can always "promote" data types from Dogs to Cats if we want to use them there, or if there is broad consensus that they would be useful to almost everyone. |
Ok, it sounds like @non has taken over the quest for NonEmptyList and that NonEmptySet is no longer a Cats related concern. I've successfully pawned my work off! 😆 You guys should close #123 and I pushed my NonEmptySet changes (which are incomplete) to a branch so they can live on in case we want to pull them into @stew's dogs. https://github.com/coltfred/cats/tree/nonEmptySet |
For a first-pass at what I'm imagining (at least for list) see here: typelevel/cats-collections#5 |
My 2¢, NonEmptySet is every bit as important as NonEmptyList. Here's an 8 month old version as syntax on OneAnd. https://gist.github.com/refried/9b68a08ff24640b86fb2 |
I trust that everyone realizes there are a ton of hidden costs to using type aliases when compared with an "equivalent" trait. You embrace a raft of additional compiler bugs - any given decision within the compiler which is made based on the type has a decent chance of failing to see through a type alias, or failing to see through a singleton type in a type alias, or a type alias in a singleton type, or etc etc. The more of these are fixed, the more unpleasant the remaining ones become, because you get that much further in some ill-fated design before the walls close in on you. It is especially debilitating when substitution is involved. See for instance one of my personal favorites, SI-8177. JIRA is presently refusing to load the 60ish older comments, but if it comes around they're worth reading so as not to underestimate what's at stake. |
@paulp I didn't realize it, although I guess I've seen hints of it. @non Indirectly related, I recently wished for a How would you see a method like this fitting into the cats ecosystem (i.e.
|
Cats should definitely have NEL in it IMO. The more I've been using it the more I find the |
Yesterday @non and I discussed this for quite a while, and we both seemed to settle on the idea that there should be a The Since |
👍 I'd like |
// If it's not clear, NonEmptyList is a |
I'm encountering NonEmptySets all the time; is there a particular reason why we get NEList and NEVector but not a NESet? I've yet to see a real-world case for NEMap though. Of course that's just my corner of the world. |
@boggle you should probably raise a separate ticket for that..? (This one is from Sep 2015.) |
NonEmptyList is currently
type NonEmptyList[A] = OneAnd[A, List]
. There has been discussion about writing a version of it that is more so that we could support a more list like interface (++, tails, sortBy, etc).How does everyone feel about it? Is it worth doing?
The text was updated successfully, but these errors were encountered: