<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thanks, Tobias. I figured it was something like that but lack the syntax expertise on where to put it.<br><br>MIchael<br><br>--- On <b>Sat, 7/24/10, Tobias Brandt <i>&lt;tob.brandt@googlemail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Tobias Brandt &lt;tob.brandt@googlemail.com&gt;<br>Subject: Re: [Haskell-cafe] Type problems<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: haskell-cafe@haskell.org<br>Date: Saturday, July 24, 2010, 3:50 PM<br><br><div id="yiv1023230428">You have to fix the type of 1 and 6, e.g. by writing<div><br></div><div>x &lt;- randomRIO (1, 6) :: IO Int</div><div><br></div><div>or</div><div><br></div><div>x &lt;- randomRIO (1, 6 :: Int)</div><div><br></div><div>&nbsp;GHCi defaults integral numbers to Int, that's why it works there.<br>
<br><div class="yiv1023230428gmail_quote">On 24 July 2010 21:36, michael rice <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:nowgate@yahoo.com" target="_blank" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="yiv1023230428gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">This works:<br><br>Prelude System.Random&gt; do { randomRIO (1,6) &gt;&gt;= (\x -&gt; putStrLn $ "Value = " ++ show x) }<br>
Value = 5<br><br>So does this:<br><br>Prelude System.Random&gt; do { x &lt;- randomRIO (1,6); putStrLn $ "Value = " ++ show x }<br>Value = 2<br><br>But not this:<br><br>1 import Control.Monad<br>2 import System.Random<br>
3<br>4 foo :: IO ()<br>5 foo = do<br>6&nbsp;&nbsp; x &lt;- randomRIO (1,6)<br>7&nbsp;&nbsp; putStrLn $ "Value = " ++ show x<br><br><br>foo.hs:6:18:<br>&nbsp;&nbsp;&nbsp; Ambiguous type variable `t' in the constraints:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `Num t' arising from the literal `1' at foo.hs:6:18<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `Random t' arising from a use of `randomRIO' at foo.hs:6:7-21<br>&nbsp;&nbsp;&nbsp; Probable fix: add a type signature that fixes these type variable(s)<br>Failed, modules loaded:
 none.<br>Prelude System.Random&gt; <br><br>Or this:<br><br>1 import Control.Monad<br>2 import System.Random<br>3<br>4 foo :: IO ()<br>5 foo = randomRIO (1,6) &gt;&gt;= (\x -&gt; putStrLn $ "Value = " ++ show x)<br>
<br><br>foo.hs:5:17:<br>&nbsp;&nbsp;&nbsp; Ambiguous type variable `t' in the constraints:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `Num t' arising from the literal `1' at foo.hs:5:17<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `Random t' arising from a use of `randomRIO' at foo.hs:5:6-20<br>
&nbsp;&nbsp;&nbsp; Probable fix: add a type signature that fixes these type variable(s)<br>Failed, modules loaded: none.<br><br><br>How to fix?<br><br>Michael<br><br><br><br><br><br></td></tr></tbody></table><br>

      <br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a rel="nofollow" ymailto="mailto:Haskell-Cafe@haskell.org" target="_blank" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a rel="nofollow" target="_blank" href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>
</div></blockquote></td></tr></table><br>