-
-
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
Add array instances #742
Comments
I think that instances for mutable structures belongs in alleycats |
Hi, coming there from codetriage. This issue has been open for quite a long time now. AFAIK, there are no Array instance in alleycat yet, so it feels like there is no progress on this issue whatsoever. Should we :
|
I am +1 on Array instances. I don’t even think they need to be in Alleycats as long as they are lawful. |
Meta point: I would like a clear law violation yet argument of utility for things in Alleycats. If we have no law violation, but somehow we don’t like it for other reasons we should be able to make a clear policy. For a long time Try was kept out of cats for some hand wavy argument about functions that throw. But functions that throw make all laws fail so I don’t see that as a valid argument. Similar to Iterable. Foldable is already lawless and really just a Typeclass generalizing a toList function. I don’t see any law violation of having Foldable for Iterable in cats. I think it kept out because scala FP programmers don’t like subclassing and usually you don’t create Iterables but treat concrete implementations as Iterables. |
Instances are only lawful for (The I can't make a good argument about |
since the array instances are lawful IF WE DON'T MUTATE, which we won't, I don't see the issue. |
Well I mean, the next question is if you're not mutating why are you using Also the |
We have to use Array to give an Array to many java libraries.
Yes, doing a `.map` will make a copy, but using a list and doing a map will
copy and then I have to copy in and out of List.
The TypeTag issue indeed probably precludes Functor and Monad, but I don't
think it has a problem for Foldable, for instance.
…On Thu, Oct 26, 2017 at 8:03 AM, Rob Norris ***@***.***> wrote:
Well I mean, the next question is if you're not mutating why are you using
Array? If you're doing it for performance then it seems unlikely you're
going to want to use these abstract operations. It seems like a marginal
use case to me that's going to lead to a lot of confusion.
Also the TypeTag issue is likely to make a bunch of instances impossible
to define. Haven't tried.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#742 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEJdsFnL1CW6FeiLaDLONgDoo8sP5jdks5swMmOgaJpZM4Gz3m_>
.
--
P. Oscar Boykin, Ph.D. | http://twitter.com/posco | http://pobox.com/~boykin
|
Ok, I'm just trying to understand what you're advocating for. Would you also want instances for |
I think someone needs to argue for an instance. To me, Array is common enough that I would like it. I personally don't use ListBuffer, so I wouldn't advocate for that, but I wouldn't push back on it either (as long as the implementation is lawful). |
Ok, thanks for clarifying. I remain 👎 for core instances that are invalid when the data type is used as intended. I'm 👍 for alley-cats, but the limitations of these instances should be clearly documented. |
In the case of Array and Foldable, how is it invalid if is you assume Array is mutable? Are you saying in another thread someone could be mutating Array without holding a lock and then we break the laws? Or are you saying that Array + Foldable seems fine? |
I think it's valid because there are no real laws, but it's not exactly fine because the operations are all side-effects if you're mutating the array; you can't inline a call to Maybe we should move |
I think there should be array instances. Probably the same as are defined for Vector
The text was updated successfully, but these errors were encountered: