Update:
So this is my code:
quadtreeToPic :: Quadtree -> Array (Int, Int) Word8
quadtreeToPic (QNode x y w avg Q0)
| w == 1 = listArray (0,0) [avg]
| w == 2 = listArray (0,4) [avg, avg, avg, avg]
quadtreeToPic (QNode x y w avg (Q4 q1 q2 q3 q4)) = listArray ((0,0), (w-1,w-1)) (concat (map quadtreeToPic [q1, q2, q3, q4]))
A Quadtree is either
QNode Int Int Int Word8 QKids
data QKids = Q0 | Q4 Quadtree Quadtree Quadtree Quadtree
The error I get is
Quadtree.hs:13:90: error:
• Couldn't match type ‘Array (Int, Int) Word8’ with ‘[Word8]’
Expected type: [[Word8]]
Actual type: [Array (Int, Int) Word8]
• In the first argument of ‘concat’, namely
‘(map quadtreeToPic [q1, q2, q3, q4])’
In the second argument of ‘listArray’, namely
‘(concat (map quadtreeToPic [q1, q2, q3, q4]))’
In the expression:
listArray
((0, 0), (w - 1, w - 1))
(concat (map quadtreeToPic [q1, q2, q3, q4]))
|
13 | quadtreeToPic (QNode x y w avg (Q4 q1 q2 q3 q4)) = listArray ((0,0), (w-1,w-1)) (concat (map quadtreeToPic [q1, q2, q3, q4]))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How do I solve this? Why is [[Word8]] expected when by definition it should expect Array (Int, Int) Word8?
w == 1 = [avg]andw == 2 = [avg, avg, avg, avg], and the type to[Word8], you furthermore probably want to uselistArray(hackage.haskell.org/package/array-0.5.3.0/docs/…) instead ofarrayin yourquadtreeToPic. Finally I'm not convinced that the logic is completely correct.‘Array (Int, Int) Word8’, I was wondering how to return the result in that particular format. I'll look intolistArray. Thanks.w == 1 = [avg]does not usearrayorlistArraythough. How would I use it?