[Haskell-beginners] 'Iterating a data type'

raeck at msn.com raeck at msn.com
Mon Dec 29 20:24:00 EST 2008

Are there anyway to express the "iterating" of a user-defined data type in 

For example, in

> data Shape = Square | Circle | Triangle

how can I 'iterate' them and apply them all to the same function without 
indicating them explicitly?
such as [func Square, func Circle, func Triangle].
Can I use a form similar to the following case in a list instead:

> Numbers = [1,2,3,4,5]

> [func x | x <- Numbers ]

Actually what I want is to obtain all the possible values of a data type 

Thank you very much!

Best wishes,


More information about the Beginners mailing list