<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hello.<br><br>I have the following data and it's constructors:<br><font style="" face="Courier New"><br></font><font style="" face="Courier New">FigType = TR1 | TR2 | TR3 | TR4 | SQ | L1 | L2 | Z1 | Z2 | Z3 | Z4 | NoFigure</font><br><br>I need to randomly return one of them in a function. The obvious solution to me, is simply using a random number generator and case statement, where each value generated is associated with each data constructor. Like this:<br><font style="" face="Courier New"><br></font><font style="" face="Courier New">import System.Random</font><font style="" face="Courier New"><br></font><font style="" face="Courier New"><br></font><font style="" face="Courier New">randomFigType :: IO FigType</font><font style="" face="Courier New"><br></font><font style="" face="Courier New">randomFigure = do</font><font style="" face="Courier New"><br></font><font style="" face="Courier New">&nbsp; x &lt;- randomRIO (1::Int,11::Int)</font><font style="" face="Courier New"><br></font><font style="" face="Courier New">&nbsp; return $ case x of</font><font style="" face="Courier New"><br></font><font style="" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 -&gt; TR1</font><font style="" face="Courier New"><br></font><font style="" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 -&gt; TR2</font><font style="" face="Courier New"><br></font><font style="" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3 -&gt; TR3</font><br>e t.c.<br><br>But is there a more direct way to do this?<br>                                               <br /><hr />Hotmail: Trusted email with Microsoft’s powerful SPAM protection. <a href='https://signup.live.com/signup.aspx?id=60969' target='_new'>Sign up now.</a></body>
</html>