<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello, <br>
<br>
Im reading chapter 2 of the CIS 194 course about enumaratuin.<br>
<br>
Now they give this example : <br>
<br>
<pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="co">-- Store a person's name, age, and favourite Thing.</span>
<span class="kw">data</span> <span class="dt">Person</span> <span class="fu">=</span> <span class="dt">Person</span> <span class="dt">String</span> <span class="dt">Int</span> <span class="dt">Thing</span>
<span class="kw">deriving</span> <span class="kw">Show</span>
<span class="ot">brent ::</span> <span class="dt">Person</span>
brent <span class="fu">=</span> <span class="dt">Person</span> <span class="st">"Brent"</span> <span class="dv">31</span> <span class="dt">SealingWax</span>
<span class="ot">stan ::</span> <span class="dt">Person</span>
stan <span class="fu">=</span> <span class="dt">Person</span> <span class="st">"Stan"</span> <span class="dv">94</span> <span class="dt">Cabbage</span>
<span class="ot">getAge ::</span> <span class="dt">Person</span> <span class="ot">-></span> <span class="dt">Int</span>
getAge (<span class="dt">Person</span> _ a _) <span class="fu">=</span> a
I understand how this works.
But I wonder if there is no "better" way to get the Age.
Is it now wise to make a person data like this :
data Person = Name : String
| Age : Integer
| FavThing : String
And if so , how can I get the age then ?
Roelof
</code></pre>
<br>
</body>
</html>