Yes, it&#39;s one things that data families do. Another is introducing *new* data types rather than reusing existing ones. - Conal<br><br><div class="gmail_quote">On Mon, Feb 14, 2011 at 1:41 PM, John Meacham <span dir="ltr">&lt;<a href="mailto:john@repetae.net">john@repetae.net</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Isn&#39;t this what data families (as opposed to type families) do?<br>
<br>
    John<br>
<div><div></div><div class="h5"><br>
On Mon, Feb 14, 2011 at 1:28 PM, Conal Elliott &lt;<a href="mailto:conal@conal.net">conal@conal.net</a>&gt; wrote:<br>
&gt; Is there a way to declare a type family to be injective?<br>
&gt;<br>
&gt; I have<br>
&gt;<br>
&gt;&gt; data Z<br>
&gt;&gt; data S n<br>
&gt;<br>
&gt;&gt; type family n :+: m<br>
&gt;&gt; type instance Z   :+: m = m<br>
&gt;&gt; type instance S n :+: m = S (n :+: m)<br>
&gt;<br>
&gt; My intent is that (:+:) really is injective in each argument (holding the<br>
&gt; other as fixed), but I don&#39;t know how to persuade GHC, leading to some<br>
&gt; compilation errors like the following:<br>
&gt;<br>
&gt;     Couldn&#39;t match expected type `m :+: n&#39;<br>
&gt;            against inferred type `m :+: n1&#39;<br>
&gt;       NB: `:+:&#39; is a type function, and may not be injective<br>
&gt;<br>
&gt; I realize that someone could add more type instances for (:+:), breaking<br>
&gt; injectivity.<br>
&gt;<br>
&gt; Come to think of it, I don&#39;t know how GHC could even figure out that the two<br>
&gt; instances above do not overlap on the right-hand sides.<br>
&gt;<br>
&gt; Since this example is fairly common, I wonder: does anyone have a trick for<br>
&gt; avoiding the injectivity issue?<br>
&gt;<br>
&gt; Thanks,  - Conal<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Glasgow-haskell-users mailing list<br>
&gt; <a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
&gt;<br>
&gt;<br>
</blockquote></div><br>