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.  Variable re-use (Shishir Srivastava)
   2. Re:  This year's Google Summer of Code (Shishir Srivastava)
   3. Re:  Variable re-use (Alexey Shmalko)
   4. Re:  Variable re-use (Grzegorz Milka)
   5. Re:  Variable re-use (Alexey Shmalko)
   6. Re:  This year's Google Summer of Code
      (Sumit Sahrawat, Maths & Computing, IIT (BHU))


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

Message: 1
Date: Tue, 28 Apr 2015 10:53:06 +0100
From: Shishir Srivastava <[email protected]>
To: beginners <[email protected]>
Subject: [Haskell-beginners] Variable re-use
Message-ID:
        <cale5rtvstzqd0ngwtrmkxrddrykapozueaxjwupy888ruvn...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,

Please can anyone explain how does 'a' get re-used in the code below. My
understanding so far of haskell is that variables are not allowed to mutate
or re-assigned.

---
do
a <- [1,2,3]
a <- [a+1]
return a

[2,3,4]
---

Thanks,
Shishir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150428/ef62fb3f/attachment-0001.html>

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

Message: 2
Date: Tue, 28 Apr 2015 11:11:02 +0100
From: Shishir Srivastava <[email protected]>
To: beginners <[email protected]>
Subject: Re: [Haskell-beginners] This year's Google Summer of Code
Message-ID:
        <cale5rts+nl_azzynpzdxwxxhlmhnuik1ybwq5txvtcg37rs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Brilliant work !

Congrats to ever so helpful Sumit Sahrawat !

Cheers,
Shishir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150428/7e479b6d/attachment-0001.html>

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

Message: 3
Date: Tue, 28 Apr 2015 10:11:47 +0000
From: Alexey Shmalko <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Variable re-use
Message-ID:
        <CAFC2PC6Eu_Okg455K_gKtoMWukx=pm77bhzg6dntquijrxi...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

If you rewrite your example without do notation, you'll get:

[1,2,3] >>= \a -> [a+1] >>= return a

You can notice that first `a` and the last one are different things. They
are just different bindings that happen to have the same name (You'll get
the shadowing warning if enable -Wall). They have nothing in common and can
have different types as well.

On Tue, Apr 28, 2015 at 12:53 PM Shishir Srivastava <
[email protected]> wrote:

> Hi,
>
> Please can anyone explain how does 'a' get re-used in the code below. My
> understanding so far of haskell is that variables are not allowed to mutate
> or re-assigned.
>
> ---
> do
> a <- [1,2,3]
> a <- [a+1]
> return a
>
> [2,3,4]
> ---
>
> Thanks,
> Shishir
>
>  _______________________________________________
> 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/20150428/08b040ed/attachment-0001.html>

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

Message: 4
Date: Tue, 28 Apr 2015 12:12:10 +0200
From: Grzegorz Milka <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Variable re-use
Message-ID: <[email protected]>
Content-Type: text/plain; charset="windows-1252"

Hi,

The variable is not reassigned, but hidden. The do notation is a
syntactic sugar for:

    [1, 2, 3] >>= (\a ->
    [a + 1] >>= (\a ->
    return a))


The second 'a' is inside a nested lambda function and therefore inside a
nested scope. The first 'a' still exists, but the value to which it
refers is hidden inside the second lambda function, where 'a' is bound
to a different value.

On 28.04.2015 11:53, Shishir Srivastava wrote:
> Hi,
>
> Please can anyone explain how does 'a' get re-used in the code below. My
> understanding so far of haskell is that variables are not allowed to mutate
> or re-assigned.
>
> ---
> do
> a <- [1,2,3]
> a <- [a+1]
> return a
>
> [2,3,4]
> ---
>
> Thanks,
> Shishir
>
>
>
> _______________________________________________
> 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/20150428/b16b5821/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150428/b16b5821/attachment-0001.sig>

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

Message: 5
Date: Tue, 28 Apr 2015 10:15:48 +0000
From: Alexey Shmalko <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Variable re-use
Message-ID:
        <CAFC2PC6mZsxz=frse2v5qfnhs_ej3sz34xucoyh_1d1nwct...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I'm sorry, my example should've been:

[1,2,3] >>= \a -> [a+1] >>= \a -> return a

On Tue, Apr 28, 2015 at 1:12 PM Grzegorz Milka <[email protected]>
wrote:

>  Hi,
>
> The variable is not reassigned, but hidden. The do notation is a syntactic
> sugar for:
>
> [1, 2, 3] >>= (\a ->
> [a + 1] >>= (\a ->
> return a))
>
>
> The second 'a' is inside a nested lambda function and therefore inside a
> nested scope. The first 'a' still exists, but the value to which it refers
> is hidden inside the second lambda function, where 'a' is bound to a
> different value.
>
> On 28.04.2015 11:53, Shishir Srivastava wrote:
>
> Hi,
>
> Please can anyone explain how does 'a' get re-used in the code below. My
> understanding so far of haskell is that variables are not allowed to mutate
> or re-assigned.
>
> ---
> do
> a <- [1,2,3]
> a <- [a+1]
> return a
>
> [2,3,4]
> ---
>
> Thanks,
> Shishir
>
>
>
>
> _______________________________________________
> Beginners mailing 
> [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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150428/3fed3435/attachment-0001.html>

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

Message: 6
Date: Tue, 28 Apr 2015 16:56:24 +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] This year's Google Summer of Code
Message-ID:
        <cajbew8oscsmc00garvjbei9sy81scdt+pcudymnckvtnd3p...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I am very humbled. Thanks, both of you.

My proposal is available at https://github.com/sumitsahrawat/gsoc, if
you're interested in knowing what I have planned to do.

On 28 April 2015 at 15:41, Shishir Srivastava <[email protected]>
wrote:

> Brilliant work !
>
> Congrats to ever so helpful Sumit Sahrawat !
>
> Cheers,
> Shishir
>
> _______________________________________________
> 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/20150428/58e8e913/attachment.html>

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 82, Issue 42
*****************************************

Reply via email to