I am attempting to have a UArray Int (Complex Double). This signature is fine, however when I try to access a specific index using (!) I receive an error. Here is the code I am attempting to use:
test :: UArray Int (Complex Double) -> Complex Double
test arr = arr ! 0
and the error I am getting:
No instance for (IArray UArray (Complex Double)) arising from a use of `!'
Possible fix:
add an instance declaration for (IArray UArray (Complex Double))
In the expression: arr ! 0
In an equation for `test': test arr = arr ! 0
This worked fone for UArray Int Double and I am curiouis as to why this does not work for (Complex Double). Thanks in advance for the help.
From the
Data.Array.Unboxed documentation, there seem to be instances ofIArraywithUArrayjust for types likeChar,DoubleorInt, not polymorphic. If you need to store values of other types, you should use boxedArray.