You strictly adhere to patterns,
resarr = IA.listArray (0,(totsize - 1)) [ score | (way,score) <- zippedList ] wayarr = IA.listArray (0,(totsize - 1)) [ way | (way,score) <- zippedList ]
which forces the elements of the array to be read during construction, which does not work.
A simple example:
module LazyArr where import Data.Array.IArray test :: Int -> (Array Int Int, Array Int Int) test n = let zippedList = map foo [0 .. n] foo :: Int -> (Int,Int) foo i | i == 0 = (0,0) | arrOne ! (i-1) < arrTwo ! (i-1) = (2,1) | even i = (i,arrTwo ! (i-1)) | otherwise = (arrOne ! (i-1),i) arrOne = listArray (0,n) $ map fst zippedList -- [a | (a,b) <- zippedList] arrTwo = listArray (0,n) $ map snd zippedList -- [b | (a,b) <- zippedList] in (arrOne, arrTwo)
works, but given the list instead of map fst respectively. map snd , it is a loop.
Thus, using the map fst zippedList version of map fst zippedList and map snd zippedList should work (like the lazy template in the list comprehensions [way | ~(way,score) <- zippedList] ), at least I donβt see any additional problems in the dependencies .
By the figurative coincidence in the cellDef k pair, cellDef k necessary to evaluate far enough to see that the top-level constructor is indeed (,) . To do this, it is necessary to determine the occupied branch, and this requires checking the contained values ββof earlier elements. But while the array is created, they still cannot be retrieved.
Each cell refers to a cell with lower indices, so the calculation must be viable
This, however, is not important. All you need is the absence of dependency cycles, and each chain leads to a specific base case.