<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I didn't try to compile this:</div><div><br></div><div>import Control.Arrow (first)</div><div>import System.Random (Random(..))</div><div><br></div>instance Random Dir where<div>&nbsp;&nbsp; &nbsp;randomR (lo, hi) gen = first fromEnum (randomR (toEnum lo) (toEnum hi) gen)</div><div>&nbsp;&nbsp; &nbsp;random gen = randomR (minBound, maxBound)</div><div><br></div><div>But something along those lines should help you I think.</div><div><br></div><div><br></div><div>-Ross</div><div><br><div><div><div>On Oct 16, 2009, at 3:36 PM, michael rice wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font: inherit;">What is the minimum I need to do to get this function to generate a three direction tuple?<br><br>Michael<br><br><br>=====================<br><br>import System.Random<br>import Data.Ord<br><br>data Dir<br>&nbsp;&nbsp;&nbsp; = North<br>&nbsp;&nbsp;&nbsp; | South<br>&nbsp;&nbsp;&nbsp; | East<br>&nbsp;&nbsp;&nbsp; | West<br>&nbsp;&nbsp;&nbsp; deriving (Show, Read, Eq, Enum, Ord, Bounded)<br><br>threeDirs :: StdGen -&gt; (Dir,Dir,Dir)<br>threeDirs gen =<br>&nbsp; let (firstDir, newGen) = random gen<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (secondDir, newGen') = random newGen<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (thirdDir, newGen'') = random newGen'<br>&nbsp; in (firstDir, secondDir, thirdDir) <br><br><br><br>=====================<br><br>GHCi, version 6.10.3: <a href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a>&nbsp; :? for help<br>Loading package ghc-prim ... linking ... done.<br>Loading package
 integer ... linking ... done.<br>Loading package base ... linking ... done.<br>Prelude&gt; :l dir.hs<br>[1 of 1] Compiling Main&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( dir.hs, interpreted )<br><br>dir.hs:15:29:<br>&nbsp;&nbsp;&nbsp; No instance for (Random Dir)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arising from a use of `random' at dir.hs:15:29-42<br>&nbsp;&nbsp;&nbsp; Possible fix: add an instance declaration for (Random Dir)<br>&nbsp;&nbsp;&nbsp; In the expression: random newGen'<br>&nbsp;&nbsp;&nbsp; In a pattern binding: (thirdDir, newGen'') = random newGen'<br>&nbsp;&nbsp;&nbsp; In the expression:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (firstDir, newGen) = random gen<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (secondDir, newGen') = random newGen<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (thirdDir, newGen'') = random
 newGen'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in (firstDir, secondDir, thirdDir)<br>Failed, modules loaded: none.<br>Prelude&gt; <br>&nbsp;<br><br></td></tr></tbody></table><br>

      _______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>http://www.haskell.org/mailman/listinfo/haskell-cafe<br></blockquote></div><br></div></div></body></html>