<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix"><br>
Maybe you will want this:<br>
<br>
<pre>data Person = Person {
name :: String,
age :: Int,
favThing :: String
}
</pre>
And get the age:<br>
<br>
<pre>getAge :: Person -> Int</pre>
<pre>getAge p = age p</pre>
<br>
Or better:<br>
<br>
<pre>getAge = age</pre>
<br>
On 02/19/2015 11:28 AM, Roelof Wobben wrote:<br>
</div>
<blockquote cite="mid:54E60F3F.4010906@home.nl" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
50 Aniversario de la Cujae. Inaugurada por Fidel el 2 de diciembre de 1964 <a href="http://cujae.edu.cu"> http://cujae.edu.cu </a>
</p>
<br/>
<IMG SRC="/etc/postfix/correo50.gif"/>
</body>
</html>