<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 19, 2015 at 2:38 PM, Ivan Lazar Miljenovic wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On 19 June 2015 at 22:09, Leza Morais Lutonda <span class="">wrote:<br>
> On 06/19/2015 03:02 AM, MigMit wrote:<br>
>><br>
>> Typo.<br>
>><br>
>> {-# LANGUAGE ConstraintKinds, GADTs #-}<br>
>> data SC c e where SC :: c d => d -> e -> SC c e<br>
><br>
><br>
> Yes, I have activated the GADTs extension too and the data definition itself<br>
> typechecks but the Show instance do not:<br>
><br>
> instance Show e => Show (S c e) where<br>
>       show (SC x y) = show x ⧺ show y<br>
><br>
> Because: Could not deduce (Show d) arising from a use of ‘show’<br>
<br>
</span>This works for me if I also enable FlexibleInstances and restrict it to:<br>
<br>
instance (Show e) => Show (S Show e) where ...<br></blockquote><div><br></div><div>Note this won't work for a <font face="monospace, monospace">Num</font> instance mentioned earlier because the existentially quantified <font face="monospace, monospace">d</font> types in two <font face="monospace, monospace">SC</font> values are not provably the same type. In other words, you can't write</div><div><br></div><div><div><font face="monospace, monospace">instance Num e => Show (S Num e) where</font></div><div><font face="monospace, monospace">    SC x1 y1 + SC x2 y2 = SC (x1 + x2) (y1 + y2)</font></div></div><div><br></div><div>because <font face="monospace, monospace">x1</font> and <font face="monospace, monospace">x2</font> can have different types.</div><div><br></div><div>Regards,</div><div>Sean</div></div></div></div>