That&#39;s strange. Here, it only fails with both NoMonomorphismRestriction and NoMonoLocalBinds (which makes sense). I&#39;ve tested on 7.4.1 and 7.6.1.<br><br>Erik<br><div class="gmail_extra"><br><br><div class="gmail_quote">

On Sun, Nov 11, 2012 at 3:54 PM, Roman Cheplyaka <span dir="ltr">&lt;<a href="mailto:roma@ro-che.info" target="_blank">roma@ro-che.info</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Apparently not — the code comilers with any of -XNoMonoLocalBinds and<br>
-XMonoLocalBinds, but not with -XNoMonomorphismRestriction.<br>
<br>
* <a href="mailto:wagnerdm@seas.upenn.edu">wagnerdm@seas.upenn.edu</a> &lt;<a href="mailto:wagnerdm@seas.upenn.edu">wagnerdm@seas.upenn.edu</a>&gt; [2012-11-09 14:07:59-0500]<br>
<div class="HOEnZb"><div class="h5">&gt; It&#39;s possible that the below blog post is related.<br>
&gt; ~d<br>
&gt;<br>
&gt; <a href="http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7" target="_blank">http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7</a><br>
&gt;<br>
&gt; Quoting Roman Cheplyaka &lt;<a href="mailto:roma@ro-che.info">roma@ro-che.info</a>&gt;:<br>
&gt;<br>
&gt; &gt;For this module<br>
&gt; &gt;<br>
&gt; &gt;    module Test where<br>
&gt; &gt;<br>
&gt; &gt;    import System.Random<br>
&gt; &gt;<br>
&gt; &gt;    data RPS = Rock | Paper | Scissors deriving (Show, Enum)<br>
&gt; &gt;<br>
&gt; &gt;    instance Random RPS where<br>
&gt; &gt;      random g =<br>
&gt; &gt;        let (x, g&#39;) = randomR (0, 2) g<br>
&gt; &gt;        in (toEnum x, g&#39;)<br>
&gt; &gt;      randomR = undefined<br>
&gt; &gt;<br>
&gt; &gt;ghc (7.4.1 and 7.6.1) reports an error:<br>
&gt; &gt;<br>
&gt; &gt;    rand.hs:9:9:<br>
&gt; &gt;        No instance for (Random t0) arising from the ambiguity check for g&#39;<br>
&gt; &gt;        The type variable `t0&#39; is ambiguous<br>
&gt; &gt;        Possible fix: add a type signature that fixes these type variable(s)<br>
&gt; &gt;        Note: there are several potential instances:<br>
&gt; &gt;          instance Random RPS -- Defined at rand.hs:7:10<br>
&gt; &gt;          instance Random Bool -- Defined in `System.Random&#39;<br>
&gt; &gt;          instance Random Foreign.C.Types.CChar -- Defined in `System.Random&#39;<br>
&gt; &gt;          ...plus 34 others<br>
&gt; &gt;        When checking that g&#39; has the inferred type `g&#39;<br>
&gt; &gt;        Probable cause: the inferred type is ambiguous<br>
&gt; &gt;        In the expression: let (x, g&#39;) = randomR (0, 2) g in (toEnum x, g&#39;)<br>
&gt; &gt;        In an equation for `random&#39;:<br>
&gt; &gt;            random g = let (x, g&#39;) = randomR ... g in (toEnum x, g&#39;)<br>
&gt; &gt;    Failed, modules loaded: none.<br>
&gt; &gt;<br>
&gt; &gt;There should be no ambiguity since &#39;toEnum&#39; determines the type of x<br>
&gt; &gt;(Int), and that in turn fixes types of 0 and 2. Interestingly,<br>
&gt; &gt;annotating 0 or 2 with the type makes the problem go away.<br>
&gt; &gt;<br>
&gt; &gt;jhc 0.8.0 compiles this module fine.<br>
&gt; &gt;<br>
&gt; &gt;Roman<br>
&gt; &gt;<br>
&gt; &gt;_______________________________________________<br>
&gt; &gt;Glasgow-haskell-users mailing list<br>
&gt; &gt;<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
&gt; &gt;<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Glasgow-haskell-users mailing list<br>
&gt; <a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
&gt; <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>
_______________________________________________<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>
</div></div></blockquote></div><br></div>