Closed Shimuuar closed 8 months ago
@lehins, @Bodigrim Any objections?
To be honest with you, I fail to see the usefulness of such type family instance for primitive types, but at the same time, I don't see anything wrong with it either. It should work for all primitive arrays, except for ByteArray, since the kind does not match for it.
Main use is to provide standard type family for Vector/MVector
like type classes which provide freezing/thawing etc. I don't quite figured it out.
In particular vector's type classes unify both slicing and array operations. If not for slicing, primitive's arrays could get Vector/MVector instances and could use all vector's machinery.
Maybe we should extract slicing functionality Vector v => Slicable v
into a separate class?
To be honest with you, I fail to see the usefulness of such type family instance for primitive types, but at the same time, I don't see anything wrong with it either.
+1.
Maybe we should extract slicing functionality
Vector v => Slicable v
into a separate class?
It's something that I would like to do. But it's rather complicated, it's quite invasive change which will break all unboxed instances. There're functions like takeWhile
which could be implemented in stream fusion framework and as a slice. API for creating slices is quite anemic too. I really should make a writeup about this
While arrays from primitive could not have
Vector
/MVector
instances,Mutable
is well defined for them. It's useful on its own and could be used with another pair of type classes.