IArray
Attempt to make IArray work
I personally think after some testing it will end up being impossible for IArray to work and that when possible, ArraySeq should be preferred.
Right now, all tests pass except stack safe traverse, but stack safe traverse fails because of a cast error, and that leads be to believe that the instance will end up being unsound in a lot of cases where it needs to cast between Array[X <: AnyVal] and Array[X <: AnyRef]
copy pasted segments of discussion from discord, maybe someone else could make this work:
if casting a
Array[Any]to anArray[Int]at runtime causes issues its not really surprising that doing the same on IArray would cause issues too ArraySeq takes special care to keep track of the runtime implementation
the issue is that IArray is an opaque type with no extra bits, so we really are just working with a raw array my hack was to summon a ClassTag[Any].asInstanceOf[T] but that obviously doesn't work with primitives however, it seems you can call getClass.getComponentType, but no clue if that would work on JS or native would be no help for fmap, or any similar thing as I need to know the exact type of the return not exact, but exact enough to get a ClassTag
ArraySeq gets around that by making its output always boxed, and it can keep track of that safely like all things IArray, it seems its relegated to only very specific, performance centered use cases
I think we could possibly solve some of these issues with a function like:
def extractClassTag[A](arr: Array[A]): ClassTag[_] = {
val componentClass = arr.getClass.getComponentType
ClassTag(componentClass)
}
and also using Class#isAssignableFrom, Class#isPrimitive and Class#isArray, I think we could solve many of the issues.
I think we need to get away from making the fake class tag from Any in every case.