title: What's the most efficient way to represent finite (non-recursive) algebraic type values?
body: <p>What's the most efficient way to serialize finite (non-recursive) algebraic-data-types which are comprised only of constructors?</p>
  
  <p>e.g. </p>
  
  <pre><code>p = A
    | B q
  
  q = C 
    | D r
    | E
  
  r = F
    | G
  </code></pre>
  
  <p>Manually enumerating all valid combinations for this trivially small definition is possible:</p>
  
  <pre><code>A      0x00
  B C    0x01
  B D F  0x02
  B D G  0x03
  B E    0x04
  </code></pre>
  
  <ul>
  <li><p>Is there any broader theory here?</p></li>
  <li><p>How about if we then add non-constructor types, such as ints, etc.?</p></li>
  <li><p>How does Haskell represent these in memory (it allows recursion, so pointers/references will probably be necessary)?</p></li>
  </ul>