The easiest way would be to use the more general fromList
function.
That way, you can just do
...
let arr = fromList (Z :. w :. h :. (3 :: Int)) ps :: Array F DIM3 Word8
return $ RGB arr
The fromList
function can be found in Data.Array.Repa.Eval
fromList :: (Shape sh, Target r e) => sh -> [e] -> Array r sh eSource
In general, you can ensure you produce the desired representation when you manifest your
arrays using the computeP
function. So, you could have done something like
the following (if you don't mind the extra copying)
let arr = fromListUnboxed (Z :. w :. h :. (3::Int)) ps :: Array U DIM3 Word8
arr2 <- computeP arr
return $ RGB arr2
The type annotation is unnecessary as the compiler knows what type it needs to
be able to use the RGB
constructor.