Continuing with my looking into CRCs via Haskell, I've written the following code to generate a table for CRC32 calculation:
crc32Table = listArray (0, 255) $ map (tbl 0xEDB88320) [0..255]
tbl polynomial byte = (iterate f byte) !! 8
where f r = xor (shift r (-1)) ((r .&. 1) * polynomial)
This correctly generates the table. I want to make frequent accesses to this table but 1) don't want to hardcode the results into code and 2) don't want to recalculate this table every time I reference it.
How would I memoize this array in Haskell? The Haskell memoization pages haven't given me any clues.