<div dir="ltr">If you aren't the one writing the code that can't be called you may never see the warning. It'll be tucked away in a cabal or stack build log somewhere.<div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 6, 2015 at 12:06 AM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">No, I want it to *warn* by default. If I write<br>
<br>
foo :: something that will fail the ambiguity check<br>
bar = something that uses foo in a (necessarily) ambiguous way<br>
<br>
the current default leads me to do this:<br>
<br>
1. Attempt to compile. Get an ambiguity error on foo whose exact cause<br>
is hard for me to see.<br>
2. Enable AllowAmbiguousTypes and recompile. Get an error on bar whose<br>
exact cause is completely obvious, and that makes it perfectly clear<br>
what I need to do to fix foo.<br>
3. Fix foo, and disable AllowAmbiguousTypes.<br>
<br>
I'd much rather go with<br>
<br>
1. Attempt to compile. Get an ambiguity *warning* on foo whose exact<br>
cause is hard for me to see, but also an error on bar whose exact<br>
cause is completely obvious, and that makes it perfectly clear what I<br>
need to do to fix foo.<br>
2. Fix foo.<br>
<br>
Simple example of how it is currently:<br>
<br>
> let foo :: Num a => F a; foo = undefined; bar :: Int; bar = foo<br>
<br>
<interactive>:14:12:<br>
    Couldn't match expected type ‘F a’ with actual type ‘F a0’<br>
    NB: ‘F’ is a type function, and may not be injective<br>
    The type variable ‘a0’ is ambiguous<br>
    In the ambiguity check for the type signature for ‘foo’:<br>
      foo :: forall a. Num a => F a<br>
    To defer the ambiguity check to use sites, enable AllowAmbiguousTypes<br>
    In the type signature for ‘foo’: foo :: Num a => F a<br>
<br>
Couldn't match what with what? Huh? Where did a0 come from?<br>
<br>
> :set -XAllowAmbiguousTypes<br>
> let foo :: Num a => F a; foo = undefined; bar :: Int; bar = foo<br>
<br>
<interactive>:16:61:<br>
    Couldn't match expected type ‘Int’ with actual type ‘F a0’<br>
    The type variable ‘a0’ is ambiguous<br>
    In the expression: foo<br>
    In an equation for ‘bar’: bar = foo<br>
<br>
Aha! That's the problem! It doesn't know what a0 is! How can I tell it<br>
what a0 is? Oh! I can't, because foo doesn't give me a handle on it.<br>
Guess I have to fix foo.<br>
<br>
I'd really, really like to get *both* of those messages in one go,<br>
with the first one preferably explaining itself a bit better.<br>
<div class="HOEnZb"><div class="h5"><br>
On Sat, Dec 5, 2015 at 11:51 PM, Edward Kmett <<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>> wrote:<br>
> So you are saying you want users to write a ton of code that happens to have<br>
> signatures that can never be called and only catch it when they go to try to<br>
> actually use it in a concrete situation much later?<br>
><br>
> I don't really show how this would be a better default.<br>
><br>
> When and if users see the problem later they have to worry about if they are<br>
> doing something wrong at the definition site or the call site. With the<br>
> status quo it complains at the right time that you aren't going to sit there<br>
> flailing around trying to fix a call site that can never be fixed.<br>
><br>
> -Edward<br>
><br>
> On Sat, Dec 5, 2015 at 5:38 PM, David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br>
>><br>
>> The ambiguity check produces errors that are quite surprising to the<br>
>> uninitiated. When the check is suppressed, the errors at use sites are<br>
>> typically much easier to grasp. On the other hand, there's obviously a lot<br>
>> of value to catching mistakes as soon as possible. Would it be possible to<br>
>> turn that into a warning by default?<br>
>><br>
>><br>
>> _______________________________________________<br>
>> ghc-devs mailing list<br>
>> <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
>><br>
><br>
</div></div></blockquote></div><br></div>