[Haskell-cafe] Understanding allocation behavior

Bulat Ziganshin bulat.ziganshin at gmail.com
Sat Apr 8 14:55:09 EDT 2006

Hello David,

Saturday, April 8, 2006, 9:58:56 PM, you wrote:

> bitsTable :: Array Word Int
> bitsTable = array (0,255) $ [(i,bitcount i) | i <- [0..255]]

bitsTable :: UArray Word Int
bitsTable = listArray (0,255) $ map bitcount [0..255]

UArray is much faster than Array but can be used only for simple datatypes
(integral, floating point, Char, Bool). more info at

btw: you can use "UArray a Bool" to represent sets of ANY type `a`
belonging to class Ix. It uses only one bit per elemnt in current

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list