title: 'type family' vs 'data family', in brief?
body: <p>I'm confused about how to choose between <code>data family</code> and <code>type family</code>. The wiki page on <a href="http://www.haskell.org/haskellwiki/GHC/Type_families#Injectivity.2C_type_inference.2C_and_ambiguity" rel="noreferrer">TypeFamilies</a> goes into a lot of detail. Occasionally it informally refers to Haskell's <code>data family</code> as a &quot;type family&quot; in prose, but of course there is also <code>type family</code> in Haskell.</p>
  <p>There is a simple example that shows where two versions of code are shown, differing only on whether a <code>data family</code> or a <code>type family</code> is being declared:</p>
  <pre><code>-- BAD: f is too ambiguous, due to non-injectivity
  -- type family F a
   
  -- OK
  data family F a 
  
  f :: F a -&gt; F a
  f = undefined
   
  g :: F Int -&gt; F Int
  g x = f x
  </code></pre>
  <p><code>type</code> and <code>data</code> here have the same meaning, but the <code>type family</code> version fails to  type-check, while the <code>data family</code> version is fine, because <code>data family</code> &quot;creates new types and are therefore injective&quot; (says the wiki page).</p>
  <p>My takeaway from all of this is &quot;try <code>data family</code> for simple cases, and, if it isn't powerful enough, then try <code>type family</code>&quot;. Which is fine, but I'd like to understand it better. Is there a Venn diagram or a decision tree I can follow to distinguish when to use which?</p>