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. Re: Numeric Integer vs Integer (goforgit .)
2. Re: Numeric Integer vs Integer (goforgit .)
3. Re: Numeric Integer vs Integer (Marcin Mrotek)
4. Re: Numeric Integer vs Integer
(Sumit Sahrawat, Maths & Computing, IIT (BHU))
----------------------------------------------------------------------
Message: 1
Date: Tue, 22 Sep 2015 16:54:00 +0200
From: "goforgit ." <[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:
<cahzzbma06c6mryr9orjpcqqoan1kc25cvbvz5chid+ylyrx...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Thanks Brandon, that cleared things up!
On Mon, Sep 21, 2015 at 8:39 PM, Brandon Allbery <[email protected]>
wrote:
>
> 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
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150922/9c14a012/attachment-0001.html>
------------------------------
Message: 2
Date: Wed, 23 Sep 2015 09:51:24 +0200
From: "goforgit ." <[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:
<CAHzzbMCWDKoGGgJOi2gqMDoSu20PTSjkoq=i+enaqgofcqs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I have a follow up question, I hope it's alright.
What about the following?
data List a = Empty | Add a (List a)
What does the a mean and why is it possible to put it there?
On Tue, Sep 22, 2015 at 4:54 PM, goforgit . <[email protected]> wrote:
> Thanks Brandon, that cleared things up!
>
> On Mon, Sep 21, 2015 at 8:39 PM, Brandon Allbery <[email protected]>
> wrote:
>
>>
>> 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
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150923/9af50450/attachment-0001.html>
------------------------------
Message: 3
Date: Wed, 23 Sep 2015 10:11:31 +0200
From: Marcin Mrotek <[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:
<CAJcfPz=VFvSuaiu13D0ahyKYFjP3Pz2Bbu=0e0-3zmeomrl...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hello,
This means that the List type is parametrized by another type. Think of it
as a sort of a function between types.
Best regards,
Marcin Mrotek
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150923/373d5160/attachment-0001.html>
------------------------------
Message: 4
Date: Wed, 23 Sep 2015 13:42:08 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
<[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:
<CAJbEW8NgkWCVQQN4opDeMGbL+bs=sAKBhBRh9_mhJ=9s2sq...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
What you wrote is equivalent to the following pseudo-haskell.
*List* takes a type and returns a new type, which represents a list of
elements of that type in this case. Thus *List* is a *type-constructor*.
It has two data-constructors, i.e. there are two ways to create elements of
the type *List a*, for any type a.
-- 'Empty' is a value of type 'List a', for all types 'a'. This is one
possible way to construct elements of type 'List a'.
Empty :: List a
-- 'Add' is a function that takes an element of type 'a', and a 'List a',
and constructs a 'List a' out of them.
Add :: a -> List a -> List a
Using the GHC extension, *GADTs*, it is possible to write code that
directly reflects this structure. Although that is considered an advanced
feature of the language.
{-# LANGUAGE GADTs #-}
data List a where
Empty :: List a
Add :: a -> List a -> List a
On 23 September 2015 at 13:21, goforgit . <[email protected]> wrote:
> I have a follow up question, I hope it's alright.
>
> What about the following?
>
> data List a = Empty | Add a (List a)
>
> What does the a mean and why is it possible to put it there?
>
>
> On Tue, Sep 22, 2015 at 4:54 PM, goforgit . <[email protected]> wrote:
>
>> Thanks Brandon, that cleared things up!
>>
>> On Mon, Sep 21, 2015 at 8:39 PM, Brandon Allbery <[email protected]>
>> wrote:
>>
>>>
>>> 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
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>>
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
--
Regards
Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150923/af55f31e/attachment.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 13
*****************************************