Possible Duplicate:
Memory footprint of Haskell data types
When solving combinatorial problems, I will often represent the solution as a bit string, eg. 1010100010110111000110... You get the picture.
I figured that when I use [Int]
for the bit string, Int
always spends the same amount of memory, no matter how big the number actually is (because Int
it's bounded, in contrast to Integer
), as the computer only remembers the bit representation, and String
's would take even more space as far as I know.
My idea was then to use the data type
data Bits = Empty | Zero Bits | One Bits deriving (Eq,Ord,Show)
But how much memory do the constructors Empty
, Zero
and One
use compared to Int
's?