<div dir="ltr">so the overlapping type families  are in HEAD?<div><br></div><div style>Awesome! I look forward to finding some time to try them out :) </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 10, 2013 at 1:56 PM, Richard Eisenberg <span dir="ltr">&lt;<a href="mailto:eir@cis.upenn.edu" target="_blank">eir@cis.upenn.edu</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>For better or worse, the new overlapping type family instances use a different overlapping mechanism than functional dependencies do. Class instances that overlap are chosen among by order of specificity; overlapping instances can be declared in separate modules. Overlapping family instances must be given an explicit order, and those that overlap must all be in the same module. The decision to make these different was to avoid type soundness issues that would arise with overlapping type family instances declared in separate modules. (Ordering a set of family instance equations by specificity, on the other hand, could easily be done within GHC.)</div>

<div><br></div><div>So, as yet, we can&#39;t fully encode functional dependencies with type families, I don&#39;t think.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Richard</div></font></span><div>

<div class="h5"><br><div><div>On Jan 2, 2013, at 4:01 PM, Martin Sulzmann &lt;<a href="mailto:martin.sulzmann.haskell@googlemail.com" target="_blank">martin.sulzmann.haskell@googlemail.com</a>&gt; wrote:</div><br><blockquote type="cite">

<br>I agree with Iavor that it is fairly straight-forward to extend FC to support FD-style type improvement. In fact, I&#39;ve formalized such a proof language in a PPDP&#39;06 paper:<br>&quot;Extracting programs from type class proofs&quot;<br>


(type improvement comes only at the end)<br><br>Similar to FC, coercions (proof terms) are used to represent type equations (improvement).<br><br>Why extend FC?<br>Why not simply use type families to encode FDs (and thus keep FC simple and small).<br>


<br>It&#39;s been a while, but as far as I remember, the encoding is only problematic in case of the combination of FDs and overlapping instances. Shouldn&#39;t this now be fixable given<br>that type family instances can be overlapping?<br>


Maybe I&#39;m missing something, guess it&#39;s also time to dig out some old notes ...<br><br>-Martin<br><br><div class="gmail_quote">On Wed, Jan 2, 2013 at 10:04 AM, Simon Peyton-Jones <span dir="ltr">&lt;<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="EN-GB">
<div><div><p class="MsoNormal" style="margin-left:36.0pt">As far as I understand, the reason that GHC does not construct such proofs is that it can&#39;t express them in its internal proof language (System FC).  <u></u><u></u></p>

<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">Iavor is quite right<u></u><u></u></span></p><div><p class="MsoNormal" style="margin-left:36.0pt">

<u></u> <u></u></p><p class="MsoNormal" style="margin-left:36.0pt">It seems to me that it should be fairly straight-forward to extend FC to support this sort of proof, but I have not been able to convince folks that this is the case.  I could elaborate, if there&#39;s interest.<u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
</div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">Iavor: I don’t think it’s straightforward, but I’m willing to be educated.  By all means start a wiki page to explain how, if you think it is. 
<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">I do agree that injective type families would be a good thing, and would deal with the main reason that fundeps are sometimes better than type families.  A
 good start would be to begin a wiki page to flesh out the design issues, perhaps linked from
<a href="http://hackage.haskell.org/trac/ghc/wiki/TypeFunctions" target="_blank">http://hackage.haskell.org/trac/ghc/wiki/TypeFunctions</a><u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">The main issues are, I think:<u></u><u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d"><span>·<span style="font:7.0pt &quot;Times New Roman&quot;">        
</span></span></span><u></u><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">How to express functional dependencies like “fixing the result type and the first argument will fix the second argument”<u></u><u></u></span></p>

<p><u></u><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d"><span>·<span style="font:7.0pt &quot;Times New Roman&quot;">        
</span></span></span><u></u><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">How to express that idea in the proof language<u></u><u></u></span></p><p class="MsoNormal">

<span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">Simon<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;" lang="EN-US"> <a href="mailto:glasgow-haskell-bugs-bounces@haskell.org" target="_blank">glasgow-haskell-bugs-bounces@haskell.org</a> [mailto:<a href="mailto:glasgow-haskell-bugs-bounces@haskell.org" target="_blank">glasgow-haskell-bugs-bounces@haskell.org</a>]
<b>On Behalf Of </b>Iavor Diatchki<br>
<b>Sent:</b> 26 December 2012 02:48<br>
<b>To:</b> Conal Elliott<br>
<b>Cc:</b> <a href="mailto:glasgow-haskell-bugs@haskell.org" target="_blank">glasgow-haskell-bugs@haskell.org</a>; GHC Users Mailing List<br>
<b>Subject:</b> Re: Fundeps and type equality<u></u><u></u></span></p>
</div>
</div><div><div><p class="MsoNormal"><u></u> <u></u></p>
<div><p class="MsoNormal">Hello Conal,<u></u><u></u></p>
<div><p class="MsoNormal"><u></u> <u></u></p>
</div>
<div><p class="MsoNormal">GHC implementation of functional dependencies is incomplete: it will use functional dependencies during type inference (i.e., to determine the values of free type variables), but it will not use them in proofs, which is what is needed in
 examples like the one you posted.  The reason some proving is needed is that the compiler needs to figure out that for each instantiation of the type `ta` and `tb` will be the same (which, of course, follows directly from the FD on the class).<u></u><u></u></p>



</div>
<div><p class="MsoNormal"><u></u> <u></u></p>
</div>
<div><p class="MsoNormal">As far as I understand, the reason that GHC does not construct such proofs is that it can&#39;t express them in its internal proof language (System FC).  It seems to me that it should be fairly straight-forward to extend FC to support this
 sort of proof, but I have not been able to convince folks that this is the case.  I could elaborate, if there&#39;s interest.<u></u><u></u></p>
</div>
<div><p class="MsoNormal"><u></u> <u></u></p>
</div>
<div><p class="MsoNormal">In the mean time, the way forward would probably be to express the dependency using type families, which I find tends to be more verbose but, at present, is better supported in GHC.<u></u><u></u></p>



</div>
<div><p class="MsoNormal"><u></u> <u></u></p>
</div>
<div><p class="MsoNormal">Cheers,<u></u><u></u></p>
</div>
<div><p class="MsoNormal">-Iavor<u></u><u></u></p>
</div>
<div><p class="MsoNormal">PS: cc-ing the GHC users&#39; list, as there was some talk of closing the ghc-bugs list, but I am not sure if the transition happened yet.<u></u><u></u></p>
</div>
<div><p class="MsoNormal"><u></u> <u></u></p>
</div>
<div><p class="MsoNormal"><u></u> <u></u></p>
</div>
<div><p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div><p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div><p class="MsoNormal">On Tue, Dec 25, 2012 at 6:15 PM, Conal Elliott &lt;<a href="mailto:conal@conal.net" target="_blank">conal@conal.net</a>&gt; wrote:<u></u><u></u></p>
<div>
<div>
<div><p class="MsoNormal" style="margin-bottom:12.0pt">I ran into a simple falure with functional dependencies (in GHC 7.4.1):<br>
<br>
&gt; class Foo a ta | a -&gt; ta<br>
&gt; <br>
&gt; foo :: (Foo a ta, Foo a tb, Eq ta) =&gt; ta -&gt; tb -&gt; Bool<br>
&gt; foo = (==)<br>
<br>
I expected that the `a -&gt; ta` functional dependency would suffice to prove that `ta ~ tb`, but<br>
<br>
    Pixie/Bug1.hs:9:7:<br>
        Could not deduce (ta ~ tb)<br>
        from the context (Foo a ta, Foo a tb, Eq ta)<br>
          bound by the type signature for<br>
                     foo :: (Foo a ta, Foo a tb, Eq ta) =&gt; ta -&gt; tb -&gt; Bool<br>
          at Pixie/Bug1.hs:9:1-10<br>
          `ta&#39; is a rigid type variable bound by<br>
               the type signature for<br>
                 foo :: (Foo a ta, Foo a tb, Eq ta) =&gt; ta -&gt; tb -&gt; Bool<br>
               at Pixie/Bug1.hs:9:1<br>
          `tb&#39; is a rigid type variable bound by<br>
               the type signature for<br>
                 foo :: (Foo a ta, Foo a tb, Eq ta) =&gt; ta -&gt; tb -&gt; Bool<br>
               at Pixie/Bug1.hs:9:1<br>
        Expected type: ta -&gt; tb -&gt; Bool<br>
          Actual type: ta -&gt; ta -&gt; Bool<br>
        In the expression: (==)<br>
        In an equation for `foo&#39;: foo = (==)<br>
    Failed, modules loaded: none.<u></u><u></u></p>
</div><p class="MsoNormal" style="margin-bottom:12.0pt">Any insights about what&#39;s going wrong here?<u></u><u></u></p>
</div><p class="MsoNormal"><span><span style="color:#888888">-- Conal</span></span><u></u><u></u></p>
</div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
Glasgow-haskell-bugs mailing list<br>
<a href="mailto:Glasgow-haskell-bugs@haskell.org" target="_blank">Glasgow-haskell-bugs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs</a><u></u><u></u></p>
</div><p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
</div>

<br>_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org" target="_blank">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
<br></blockquote></div><br>
_______________________________________________<br>Glasgow-haskell-users mailing list<br><a href="mailto:Glasgow-haskell-users@haskell.org" target="_blank">Glasgow-haskell-users@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>

</blockquote></div><br></div></div></div><br>_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
<br></blockquote></div><br></div>