<div dir="ltr">On Sun, Aug 2, 2015 at 12:58 PM, Daniel Bergey <span dir="ltr"><<a href="mailto:bergey@teallabs.org" target="_blank">bergey@teallabs.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2015-07-31 at 08:59, Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<br>
<span>> Daniel Bergey wrote:<br>
> |  How hard would it be to give a different error message instead of "No<br>
> |  instance ..." when the type variable is ambiguous?  I always find this<br>
> |  error slightly misleading, since it seems to me that there are<br>
> |  multiple valid instances, not that there is "no instance".<br>
><br>
> What would you like it to say?  I think it likely we could make it say that!<br>
<br>
</span>Great!  I'd like it to say "Multiple instances for ..."  or "No unique<br>
instance for ...".  I have a slight preference for the former.<br></blockquote><div><br></div><div>It may be worth noting that the existing error message is actually technically<br></div><div>correct, in the sense that what would be needed for the program to compile<br></div><div>is exactly an instance of the form "instance Foldable t where ...". Then the<br></div><div>compiler would know that the ambiguity in the type variable t0 doesn't matter.<br></div><div>It doesn't make any difference whether there are zero, one, or multiple instances<br></div><div>of Foldable for more specific types. (Except in that if there is at least one<br></div><div>such instance, then there can't also be an "instance Foldable t" assuming<br></div><div>that OverlappingInstances is not enabled.) Once you understand this, the error<br>message makes perfect sense. But it is often confusing to beginners.<br></div><div><br>"Multiple instances for (C t)" seems bad because there might not be any<br></div><div>instances for C at all. "No unique instance for (C t)" is better most of the time,<br></div><div>but it doesn't exactly get to the core of the issue, since there could be just one<br></div><div>instance of C, for a specific type, and then it is no better than "No instance for<br></div><div>(C t)". If I were to explain the situation, I would say "there is no single instance<br></div><div>(C t) that applies for every type t", but it seems a bit wordy for a compiler error...<br><br></div><div>Regards,<br></div><div>Reid Barton<br></div></div></div></div>