<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">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></table><br>