title: Expand type synonyms, type families with GHCi
body: <p>I am wondering if there is functionality that exists within GHCi (or elsewhere) to expand type synonyms and families out of an arbitrary type expression.</p>
  
  <p>For example, if I have these types,</p>
  
  <pre><code>data A = A
  data B = B
  
  data F a = F a
  data G a = G a
  data H a b = H a b
  
  type S a b = H (F a) (G b)
  type T a = S (a) (H B a)
  
  type family R a :: *
  type instance R (H a b) = H b a
  </code></pre>
  
  <p>then I would like to be able to get this kind of output in a ghci session.</p>
  
  <pre><code>&gt; :t undefined :: T (S B A)
  undefined :: T (S B A) :: T (S B A)
  
  &gt; :texpand undefined :: T (S B A)
  undefined :: T (S B A) :: H (F ((H (F B) (G A)))) (G (H B (H (F B) (G A))))
  
  &gt; :texpand undefined :: R (T (S B A))
  undefined :: R (T (S B A)) :: H (G (H B (H (F B) (G A)))) (F ((H (F B) (G A)))) 
  </code></pre>
  
  <p>As far as I can tell, GHCi doesn't actually provide anything like a <code>:texpand</code> command, and I'm not sure that it would be the best interface for that information anyway.  However, it seems likely that expanded types can be extracted from GHC somehow, and I would really like to be able to see them interactively.</p>
  
  <p>Hacks, documentation links, speculative discussion about future additions to GHCi all welcome.</p>