Possible duplicate:
Memory for Haskell Data Types
When solving combinatorial problems, I often present the solution as a bit string, for example. 1010100010110111000110 ... You get an image.
I realized that when I use [Int] for a bit string, Int always spends as much memory as this number would actually be (because Int is limited, unlike Integer ), since the computer only remembers the bit representation , and String will take up even more space as far as I know.
My idea was to use a data type
data Bits = Empty | Zero Bits | One Bits deriving (Eq,Ord,Show)
But how much memory do the Empty , Zero and One constructors use compared to Int 's?
Undreren
source share