Hi,<br><br><div class="gmail_quote">On 11 March 2012 15:57, Peter Hall <span dir="ltr">&lt;<a href="mailto:peter.hall@memorphic.com">peter.hall@memorphic.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Can someone remind me why I can&#39;t do this:<br>
<br>
<br>
    data Digit = D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9<br>
        deriving (Eq, Ord, Show)<br>
<br>
    instance Num [Digit] where ...  -- This isn&#39;t allowed<br></blockquote><div><br></div><div>Why is it not allowed? Yes, it needs FlexibleInstances, but this is a fairly common language extension so shouldn&#39;t be a big problem for most use cases.</div>

<div><br></div><div>The error message generated by ghc should tell you about this. Following is what I get for example:</div><div><br></div><div><div><font face="&#39;courier new&#39;, monospace">Illegal instance declaration for `Num [Digit]&#39;</font></div>

<div><font face="&#39;courier new&#39;, monospace">      (All instance types must be of the form (T a1 ... an)</font></div><div><font face="&#39;courier new&#39;, monospace">       where a1 ... an are *distinct type variables*,</font></div>

<div><font face="&#39;courier new&#39;, monospace">       and each type variable appears at most once in the instance head.</font></div><div><font face="&#39;courier new&#39;, monospace">       Use -XFlexibleInstances if you want to disable this.)</font></div>

<div><font face="&#39;courier new&#39;, monospace">    In the instance declaration for `Num [Digit]&#39;</font></div></div><div><br></div><div>HTH,</div><div>Ozgur</div></div><br>