<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Thanks, <br>
      <br>
      That is not what I mean , <br>
      <br>
      I mean this : <br>
      <br>
      <span class="kw1">data</span> Person <span class="sy0">=</span>
      Person<br>
            <span class="br0">{</span> name <span class="sy0">::</span>
      <span class="kw4">String</span> ,<br>
              Age <span class="sy0">::</span> Integer<span class="kw4"></span>
      , <br>
              FavThing <span class="sy0">::</span> <span class="kw4">String</span> <span
        class="kw4"></span> <span class="br0">}</span>
      <br>
      <br>
      <br>
      and i want to get the Age I could do this : <br>
      <br>
      getAge <span class="br0">(Person</span> <span class="br0">{age</span>
      <span class="sy0">=</span> ag})<span class="br0"></span> <span
        class="sy0">=</span> ag<br>
      <br>
      Roelof<br>
      <br>
      <span class="br0"></span>
      <br>
      Sumit Sahrawat, Maths & Computing, IIT (BHU) schreef op
      19-2-2015 om 17:37:<br>
    </div>
    <blockquote
cite="mid:CAJbEW8McB7=yzdyQxxLQS_pnE242sNB+YAcvwwefWPP9TWCQ1Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>I can't understand what you mean by those colons in the
          second definition of Person. If you're thinking of type
          signatures, then that doesn't work in haskell.</div>
        <div>In an ADT, you give names to possible values. So "Name
          String" will work whereas "Name : String" won't work.</div>
        <div><br>
        </div>
        <div><font face="monospace, monospace">data Person = Name String</font></div>
        <div><font face="monospace, monospace">            | Age Integer</font></div>
        <div><font face="monospace, monospace">            | FavThing
            String</font></div>
        <div><font face="monospace, monospace"><br>
          </font></div>
        means that Person can be <b><i>one of</i></b> these things
        (which is not what you want).
        <div><br>
        </div>
        <div>What you want is possible with record syntax. He'll detail
          it later I think.</div>
        <div>If you're interested in learning about it beforehand, look
          it up in the haskell wikibook (another great haskell
          resource).</div>
        <div><br>
        </div>
        <div>More about ADTs in general:    <a moz-do-not-send="true"
href="http://en.wikibooks.org/wiki/Haskell/Type_declarations#data_and_constructor_functions">http://en.wikibooks.org/wiki/Haskell/Type_declarations#data_and_constructor_functions</a></div>
        <div>The link to the specific section: <a moz-do-not-send="true"
href="http://en.wikibooks.org/wiki/Haskell/More_on_datatypes#Named_Fields_.28Record_Syntax.29">http://en.wikibooks.org/wiki/Haskell/More_on_datatypes#Named_Fields_.28Record_Syntax.29</a></div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On 19 February 2015 at 21:58, Roelof
          Wobben <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div 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><code><span>-- Store a person's name, age, and favourite Thing.</span>
<span>data</span> <span>Person</span> <span>=</span> <span>Person</span> <span>String</span> <span>Int</span> <span>Thing</span>
  <span>deriving</span> <span>Show</span>

<span>brent ::</span> <span>Person</span>
brent <span>=</span> <span>Person</span> <span>"Brent"</span> <span>31</span> <span>SealingWax</span>

<span>stan ::</span> <span>Person</span>
stan  <span>=</span> <span>Person</span> <span>"Stan"</span> <span>94</span> <span>Cabbage</span>

<span>getAge ::</span> <span>Person</span> <span>-></span> <span>Int</span>
getAge (<span>Person</span> _ a _) <span>=</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>
            </div>
            <br>
            _______________________________________________<br>
            Beginners mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
            <a moz-do-not-send="true"
              href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners"
              target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div class="gmail_signature">
          <div dir="ltr">
            <div>
              <div dir="ltr">
                <div dir="ltr">
                  <div>Regards</div>
                  <div dir="ltr">
                    <div><br>
                    </div>
                    <div>Sumit Sahrawat</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <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>