On Mon, Dec 29, 2008 at 6:24 PM,  <span dir="ltr">&lt;<a href="mailto:raeck@msn.com">raeck@msn.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Are there anyway to express the &quot;iterating&quot; of a user-defined data type in Haskell?<br>
<br>
For example, in<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
data Shape = Square | Circle | Triangle<br>
</blockquote>
<br>
how can I &#39;iterate&#39; them and apply them all to the same function without indicating them explicitly?<br>
such as [func Square, func Circle, func Triangle].<br>
Can I use a form similar to the following case in a list instead:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Numbers = [1,2,3,4,5]<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
[func x | x &lt;- Numbers ]<br>
</blockquote>
<br>
Actually what I want is to obtain all the possible values of a data type (Shape).</blockquote><div><br>For &quot;enum&quot; style data, where all the constructors have no arguments, you can do deriving (Bounded, Enum), so:<br>
<br>data Shape = Square | Circle | Triangle<br>&nbsp; deriving (Bounded,Enum)<br><br>Then:<br><br>numbers = [minBound..maxBound] :: [Shape]<br><br>Luke<br></div></div>