Mkay.  I get it now.  I was under the impression that, essentially, a data family was precisely equivalent to a type family aliasing to a separately declared datatype.<br><br>One more question: is there any way to get the low overhead of newtypes for particular instances of a data family?  Is this impossible?  That is, is there any way to do something like<br>

<br>data family Foo a<br>data instance Foo Int = Bar Int -- Bar is actually a newtype<br><br clear="all">Louis Wasserman<br><a href="mailto:wasserman.louis@gmail.com">wasserman.louis@gmail.com</a><br>
<br><br><div class="gmail_quote">On Thu, Apr 2, 2009 at 12:47 PM, David Menendez <span dir="ltr">&lt;<a href="mailto:dave@zednenem.com">dave@zednenem.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

2009/4/2 Louis Wasserman &lt;<a href="mailto:wasserman.louis@gmail.com">wasserman.louis@gmail.com</a>&gt;:<br>
<div class="im">&gt; Mkay.  One more quick thing -- the wiki demonstrates a place where the<br>
&gt; original attempt worked, with a data family instead. (That is, replacing<br>
&gt; &#39;type&#39; with &#39;data&#39; and adjusting the instance makes this program compile<br>
&gt; immediately.)<br>
&gt; a) Is there a type-hackery reason this is different from data families?<br>
<br>
</div>It&#39;s not type hackery. Data families are different from type families,<br>
and the syntax for declaring instances of higher-kinded families is a<br>
consequence of those differences.<br>
<br>
An instance of a data family is a new type constructor, so you have to<br>
provide the additional arguments in order to declare the data<br>
constructors.<br>
<br>
data family Foo a :: * -&gt; *<br>
data instance Foo Bool a = FB a a<br>
-- Foo Bool has kind * -&gt; *, like [], so I could make it a Functor<br>
<br>
Instance of type families are always pre-existing type constructors.<br>
<br>
type family Bar a :: * -&gt; *  -- Bar a must equal something of kind * -&gt; *<br>
type instance Bar () = Maybe<br>
<div class="im"><br>
&gt; b) Is there a reason this isn&#39;t made a lot clearer in the documentation?<br>
&gt;  GHC&#39;s docs say that higher-order type families can be declared with kind<br>
&gt; signatures, but never gives any examples -- which would make it a lot<br>
&gt; clearer that the below program doesn&#39;t work.<br>
<br>
</div>Here&#39;s a higher-kinded type family I&#39;ve used.<br>
<br>
type family Sig t :: * -&gt; *<br>
<br>
class (Traversable (Sig t)) =&gt; Recursive t where<br>
    roll :: Sig t t -&gt; t<br>
    unroll :: t -&gt; Sig t t<br>
<br>
<br>
The Traversable context wouldn&#39;t be valid if I had declared Sig t a ::<br>
*, because type families must always be fully applied.<br>
<br>
<br>
The difference is analogous to the difference between<br>
<br>
type M0 a = StateT Int IO a<br>
type M1   = StateT Int IO<br>
<br>
Since type synonyms (like type and data families) must always be fully<br>
applied, you can use M1 in places where you can&#39;t use M0, even though<br>
they&#39;re effectively the same thing.<br>
<br>
foo :: ErrorT String M1 a -- valid<br>
bar :: ErrorT String M0 a -- not valid<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Dave Menendez &lt;<a href="mailto:dave@zednenem.com">dave@zednenem.com</a>&gt;<br>
&lt;<a href="http://www.eyrie.org/%7Ezednenem/" target="_blank">http://www.eyrie.org/~zednenem/</a>&gt;<br>
</font></blockquote></div><br>