<div class="gmail_quote">On Fri, May 28, 2010 at 2:36 AM, Isaac Dupree <span dir="ltr">&lt;<a href="mailto:ml@isaac.cedarswampstudios.org">ml@isaac.cedarswampstudios.org</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;">
<div><div></div><div class="h5">On 05/27/10 17:42, Carlos Camarao wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">
On Thu, May 27, 2010 at 5:43 PM, David Menendez&lt;<a href="mailto:dave@zednenem.com" target="_blank">dave@zednenem.com</a>&gt;  wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">
On Thu, May 27, 2010 at 10:39 AM, Carlos Camarao<br>
&lt;<a href="mailto:carlos.camarao@gmail.com" target="_blank">carlos.camarao@gmail.com</a>&gt;  wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Isaac Dupree:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Your proposal appears to allow /incoherent/ instance selection.<br>
This means that an expression can be well-typed in one module, and<br>
well-typed in another module, but have different semantics in the<br>
two modules.  For example (drawing from above discussion) :<br>
<br>
module C where<br>
<br>
class F a b where f :: a -&gt;  b<br>
class O a where o :: a<br>
<br>
module P where<br>
import C<br>
<br>
instance F Bool Bool where f = not<br>
instance O Bool where o = True<br>
k :: Bool<br>
k = f o<br>
<br>
module Q where<br>
import C<br>
instance F Int Bool where f = even<br>
instance O Int where o = 0<br>
k :: Bool<br>
k = f o<br>
<br>
module Main where<br>
import P<br>
import Q<br>
-- (here, all four instances are in scope)<br>
main = do { print P.k ; print Q.k }<br>
-- should result, according to your proposal, in<br>
-- False<br>
-- True<br>
-- , am I correct?<br>
</blockquote>
<br>
If qualified importation of k from both P and from Q was specified, we<br>
would have two *distinct* terms, P.k and Q.k.<br>
</blockquote>
<br>
I think Isaac&#39;s point is that P.k and Q.k have the same definition (f<br>
o). If they don&#39;t produce the same value, then referential<br>
transparency is lost.<br>
<br>
--<br>
Dave Menendez&lt;<a href="mailto:dave@zednenem.com" target="_blank">dave@zednenem.com</a>&gt;<br></div></div>
&lt;<a href="http://www.eyrie.org/%7Ezednenem/" target="_blank">http://www.eyrie.org/~zednenem/</a>&lt;<a href="http://www.eyrie.org/%7Ezednenem/" target="_blank">http://www.eyrie.org/%7Ezednenem/</a>&gt;&gt;<br>
<br>
</blockquote><div class="im">
<br>
The definitions of P.k and Q.k are textually the same but the contexts are<br>
different. &quot;f&quot; and &quot;o&quot; denote distinct values in P and Q. Thus, P.k and Q.k<br>
don&#39;t have the same definition.<br>
</div></blockquote>
<br>
Oh, I guess you are correct: it is like defaulting: it is a similar effect where the same expression means different things in two different modules as if you had default (Int) in one, and default (Bool) in the other.  Except: Defaulting according to the standard only works in combination with the 8 (or however many it is) standard classes; and defaulting in Haskell is already a bit poorly designed / frowned upon / annoying that it&#39;s specified per-module when nothing else in the language is*.(that&#39;s a rather surmountable argument)  </blockquote>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
It may be worth reading the GHC user&#39;s guide which attempts to explain the difference between incoherent and non-incoherent instance selection,<br>
<a href="http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/type-class-extensions.html#instance-overlap" target="_blank">http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/type-class-extensions.html#instance-overlap</a><br>

I didn&#39;t read both it and your paper closely enough that I&#39;m sure anymore whether GHC devs would think your extension would require or imply -XIncoherentInstances ... my intuition was that IncoherentInstances would be implied...<br>

<br>
*(it&#39;s nice when you can substitute any use of a variable, such as P.k, with the expression that it is defined as -- i.e. the expression written so that it refer to the same identifiers, not a purely textual substitution -- but in main above, you can&#39;t write [assuming you imported C] &quot;print (f o)&quot; because it will be rejected for ambiguity. (Now, there is already an instance-related situation like this where Main imports two different modules that define instances that overlap in an incompatible way, such as two different instances for Functor (Either e) -- not everyone is happy about how GHC handles this, but at least those overlaps are totally useless and could perhaps legitimately result in a compile error if they&#39;re even imported into the same module.))<br>

_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>I have no idea why you think IncoherentInstances would be implied. The proposal says: do not issue ambiguity error if, using whatever means
 permitted and specified (OverlappingInstances, IncoherentInstances, 
whatever),  you can select a single instance. <br>
<br>
The situation is as if we a FD:<br><br>module C 
where<br>  class F a b | a-&gt;b where f :: a -&gt;  b<br>  class O a where o :: a <br><br>

module P where <br>  import C; 
instance F Bool Bool where f = not<br>  instance O Bool where o = True<br>  g:: Bool -&gt; Bool<br>  g = f<br>  k::Bool<br>  k = g o<br>

<br>module Q where<br>  import C<br>  instance F Int Bool where f = even<br>  instance O Int where o = 0<br>  g::Int-&gt;Bool<br>  g = f<br>  k :: Bool<br>  k = g o<br><br>
module Main where<br>  
import P<br>  
import Q<br>   main = do { print P.k ; print Q.k }   

<br><br>Cheers, <br><br>Carlos<br><br>