Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Numeric Integer vs Integer (goforgit .)
   2. Re:  Numeric Integer vs Integer (Brandon Allbery)


----------------------------------------------------------------------

Message: 1
Date: Mon, 21 Sep 2015 20:23:33 +0200
From: "goforgit ." <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Numeric Integer vs Integer
Message-ID:
        <CAHzzbMBjroXjBymPZCPJfeAe1Pd2=upqu-c1wf5dw3lxtzr...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello!

Could someone explain to me the difference between the following?

data Atype = Numeric Integer | A | B C

and

data Atype = Integer | A | B C

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150921/840da43d/attachment-0001.html>

------------------------------

Message: 2
Date: Mon, 21 Sep 2015 14:39:51 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Numeric Integer vs Integer
Message-ID:
        <CAKFCL4VaCQ5GyEo=asn4xw061fyvkb2rahewprgow47kjut...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Mon, Sep 21, 2015 at 2:23 PM, goforgit . <[email protected]> wrote:

> Could someone explain to me the difference between the following?
>
> data Atype = Numeric Integer | A | B C
>
> and
>
> data Atype = Integer | A | B C
>

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.
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.

Note that the "Integer" in the second one has *nothing whatsoever* to do
with the *type* Integer.

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.

-- 
brandon s allbery kf8nh                               sine nomine associates
[email protected]                                  [email protected]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150921/5740ab9b/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 87, Issue 12
*****************************************

Reply via email to