title: Is it possible to have recursive sum type, with each 'level' having distinct value?
body: <p>I was wondering if it is possible (I guess it is :) ) to have recursive sum type where we have a value of type X on every level, but somehow restrict ourselves that on every level of recursion we have distinct value of X?</p>
  
  <p>For example, if I have</p>
  
  <pre class="lang-hs prettyprint-override"><code>data MachineType = Worker | Flyer | Digger | Observer | Attacker
  data Machine = Single MachineType | Multi MachineType Machine
  </code></pre>
  
  <p>type system would allow me to construct Machine with following type:</p>
  
  <pre class="lang-hs prettyprint-override"><code>Multi Worker (Multi Worker (Single Worker))
  </code></pre>
  
  <p>but I want this to be restricted, so that only different MachineType-s are allowed.</p>
  
  <p>Is there a way to encode this in type system?</p>
  
  <p>You can just point me in the right direction, as I kinda don't know what to google :) (haskell set-like recursive sum types?)</p>