haskell-repa / repa

High performance, regular, shape polymorphic parallel arrays.
repa.ouroborus.net
138 stars 36 forks source link

Lack of functionality for ByteString Arrays. #18

Open ahgibbons opened 7 years ago

ahgibbons commented 7 years ago

The Data.Array.Repa.Repr.ByteString module provides a way to make arrays from ByteString types using fromByteString. The resulting array has the type Array B sh Word8. It seems that this type is not very useful as there is no equivalent of computeS or computeP for this representation type. Importantly, there seems to be no way to convert any other type of array to an Array B.

Is this implementation incomplete?

tmcdonell commented 7 years ago

I guess it needs an instance for Target. I don't know if it is that this can not be implemented, if it was just not done yet... if you try it out and it works send a PR? (:

tmcdonell commented 7 years ago

iirc ByteString is backed by ForeignPtr, which has a Target instance already, so this should be doable.

rcannon commented 2 years ago

@tmcdonell It does seem that the implementation of Target is a bit tricky, since Data.ByteString does not have a mutable interface. For example, newMVec is easy for vector because of the Data.Vector.Mutable.new function, but there is no equivalent for ByteString. One way around this is to just define everything in terms of ForeignPtr Word8 which would mean the Target class looks identical to that for ForeignPtr but with e specified to Word8. This might be desired just for completeness of the module.