<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 21, 2015 at 2:23 PM, goforgit . <span dir="ltr"><<a href="mailto:teztingit@gmail.com" target="_blank">teztingit@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Could someone explain to me the difference between the following?<br><br></div><span style="font-family:monospace,monospace">data Atype = Numeric Integer | A | B C<br></span><span style="font-family:arial,helvetica,sans-serif"><br></span></div><span style="font-family:arial,helvetica,sans-serif">and</span><span style="font-family:monospace,monospace"><br><br>data Atype = Integer | A | B C</span><br></blockquote></div><div class="gmail_extra"><br></div>The second one is an enumeration with three values: "Integer" (which is *not* an integer, nor does it contain one), "A", and "B" which as written there takes a value of some unspecified type C as a parameter.</div><div class="gmail_extra">The first one is a enumeration with three values: "Numeric" which takes an Integer as a parameter, "A", and "B" which takes a value of some unspecified type C as a parameter.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Note that the "Integer" in the second one has *nothing whatsoever* to do with the *type* Integer.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Remember that you must always provide a data constructor with "data"; you cannot simply say "data MyInt = Integer" to "wrap" an Integer, because you have not said what to wrap it *in*. (You may have intended to create a type alias, though; that would be "type", not "data".) A "data" always requires a data constructor name, so the compiler can tell when you are talking about a value of that type by looking for the constructor.<br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div></div>