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