haskellrepa

An array of triplets in repa checked at compile time


First of all, I'm a total newbie in repa and I still consider myself a beginner in Haskell in general.

I need an effective array of triplets of doubles. The naïve approach would be [(Double, Double, Double)] but that's not effective. I thought I could use repa as it is supposed to be very effective. However, I don't know how should I define an array of triplets.

I could do Array U DIM2 Double and store the elements of the triplets in the second dimension (i.e. first index is the index of the triplet and the second index is the element of the triplet). However there is nothing that forces the second dimension to be only of size 3.

I need something like Array U DIM1 Vec3D but that's not possible as Vec3D is not instance of Data.Vector.Unboxed.Base.Unbox.


Solution

  • I may be reading the documentation wrong, but I think Array U DIM1 (Double,Double,Double) is exactly what you want (why don't you try it?). Before you tell me it is inefficient: