[Haskell-cafe] represent data sturcture using function

Raeck chiu raeck at msn.com
Mon Dec 29 00:04:28 EST 2008

Merry Christmas!
Hope everybody is enjoying the Christmas!

I am doing some readings and I found something seems to be interesting.

People sometime will try to represent a quantity-regard-only data structure
(such a order-regadless List) using functions instead of ta concrete data
structure (like the haskell build-in []), any particular reason for this?

For example,
> data Sex = Male | Female
> classA :: Sex -> Int
> classA Male = 100
> classA Female = 200

when I should prefer the above solution instead of using a concrete data structure
such as [] to represent the classA members?

It seems to be very difficult to change the number of Male or Female if a concrete data
structure is not used. Is it possible change the number of Male in classA when represent
classA using function?

Thank you very much!

Best wishes,

It’s the same Hotmail®. If by “same” you mean up to 70% faster.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081229/78f7e2f7/attachment.htm

More information about the Haskell-Cafe mailing list