algebra icon indicating copy to clipboard operation
algebra copied to clipboard

Array instances

Open rklaehn opened this issue 10 years ago • 5 comments

Add instances for arrays.

Arrays are essential in many cases for compact representation, so I think having array instances would be good.

I care most about really basic things like Eq[A] and Order[A], but I guess it would do no harm to just copy everything applicable to algebra from https://github.com/non/spire/blob/master/core/shared/src/main/scala/spire/std/array.scala

rklaehn avatar Dec 09 '15 12:12 rklaehn

Agree totally.

denisrosset avatar Dec 09 '15 15:12 denisrosset

Should this use @specialized or not?

rklaehn avatar Dec 09 '15 20:12 rklaehn

Thanks @rklaehn, I guess the issue can be closed!

denisrosset avatar Dec 10 '15 12:12 denisrosset

Well, it depends. There are a lot of instances that we could provide. I just copied over the essential (for me) ones. But I think we should at least provide Monoid before we close the issue.

rklaehn avatar Dec 10 '15 12:12 rklaehn

We probably want a few:

def concatMonoid[T: ClassTag]: Monoid[Array[T]]
// then the usual vector space style ones, which are probably what people want:
def extendingPointwiseSemigroup[T: ClassTag: Semigroup]: Semigroup[Array[T]]
// you can do pretty much everything this way in core except Field, I think.
// It is a shame we have to write those all out. Maybe macros could help here.

johnynek avatar Dec 10 '15 17:12 johnynek