Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/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. anonymous arguments (harry)
2. Re: anonymous arguments (Tony Morris)
3. Re: anonymous arguments (harry)
4. Re: anonymous arguments (Twan van Laarhoven)
5. Re: anonymous arguments (harry)
6. Re: anonymous arguments (David McBride)
----------------------------------------------------------------------
Message: 1
Date: Sun, 29 Dec 2013 12:17:20 +0000 (UTC)
From: harry <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] anonymous arguments
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Is there any reason not to include Scala-like anonymous arguments in
Haskell? For example, I would like to write
map (\x -> foo x 3)
as
map (foo _ 3)
The named argument in this and similar cases adds nothing but visual and
namespace clutter.
------------------------------
Message: 2
Date: Sun, 29 Dec 2013 22:37:51 +1000
From: Tony Morris <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] anonymous arguments
Message-ID:
<cajf6usjxzco5z3q5mbn3wj2+d0af1mzjtn85cpaewt6ouf+...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
(`foo` 3)
Scala is very limited when it comes to this point free code.
On 29/12/2013 10:17 PM, "harry" <[email protected]> wrote:
> Is there any reason not to include Scala-like anonymous arguments in
> Haskell? For example, I would like to write
> map (\x -> foo x 3)
> as
> map (foo _ 3)
>
> The named argument in this and similar cases adds nothing but visual and
> namespace clutter.
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131229/a13f7183/attachment-0001.html>
------------------------------
Message: 3
Date: Sun, 29 Dec 2013 12:47:48 +0000 (UTC)
From: harry <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] anonymous arguments
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Tony Morris <tmorris <at> tmorris.net> writes:
>
>
> (`foo` 3)
> Scala is very limited when it comes to this point free code.
>
> On 29/12/2013 10:17 PM, "harry" <voldermort <at> hotmail.com> wrote:
>
> Is there any reason not to include Scala-like anonymous arguments in
> Haskell? For example, I would like to write
> ? map (\x -> foo x 3)
> as
> ? map (foo _ 3)
> The named argument in this and similar cases adds nothing but visual and
> namespace clutter.
How about a slightly more complex example?
map (\x -> foo 4 'f' (bar x) 5 'j')
There comes a point where point-free notation becomes unreadable.
------------------------------
Message: 4
Date: Sun, 29 Dec 2013 14:24:13 +0100
From: Twan van Laarhoven <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] anonymous arguments
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
On 2013-12-29 13:47, harry wrote:
> Tony Morris <tmorris <at> tmorris.net> writes:
>>
>>
>> (`foo` 3)
>> Scala is very limited when it comes to this point free code.
>>
>> On 29/12/2013 10:17 PM, "harry" <voldermort <at> hotmail.com> wrote:
>>
>> Is there any reason not to include Scala-like anonymous arguments in
>> Haskell? For example, I would like to write
>> map (\x -> foo x 3)
>> as
>> map (foo _ 3)
>> The named argument in this and similar cases adds nothing but visual and
>> namespace clutter.
>
> How about a slightly more complex example?
>
> map (\x -> foo 4 'f' (bar x) 5 'j')
>
> There comes a point where point-free notation becomes unreadable.
If you write
map (foo 4 'f' (bar _) 5 'j')
How would the compiler know whether you meant
map (\x -> foo 4 'f' (bar x) 5 'j')
or
map (foo 4 'f' (\x -> bar x) 5 'j')
?
Lambda's make it explicit where the variable is bound, which is a good thing,
IMO.
Twan
------------------------------
Message: 5
Date: Sun, 29 Dec 2013 13:39:36 +0000 (UTC)
From: harry <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] anonymous arguments
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Twan van Laarhoven <twanvl <at> gmail.com> writes:
> If you write
>
> map (foo 4 'f' (bar _) 5 'j')
>
> How would the compiler know whether you meant
>
> map (\x -> foo 4 'f' (bar x) 5 'j')
> or
> map (foo 4 'f' (\x -> bar x) 5 'j')
> ?
Interesting question, what does Scala do for this? I guess there would be a
rule of always binding to the outermost or innermost scope.
------------------------------
Message: 6
Date: Sun, 29 Dec 2013 16:27:08 -0500
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] anonymous arguments
Message-ID:
<CAN+Tr41wkq5xte=tu26dpcsjmpwokao9m2-y-suybbftkuv...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I've seen the question asked on stackoverflow before. It will be a very
subtle bug that scala does not catch for you. You just have to have the
discpline not to nest multiple anonymous functions with underscore
arguments. There's no way for the compiler to disallow it because it
cannot tell a mistake from something that is intentional.
On Sun, Dec 29, 2013 at 8:39 AM, harry <[email protected]> wrote:
> Twan van Laarhoven <twanvl <at> gmail.com> writes:
>
> > If you write
> >
> > map (foo 4 'f' (bar _) 5 'j')
> >
> > How would the compiler know whether you meant
> >
> > map (\x -> foo 4 'f' (bar x) 5 'j')
> > or
> > map (foo 4 'f' (\x -> bar x) 5 'j')
> > ?
>
> Interesting question, what does Scala do for this? I guess there would be a
> rule of always binding to the outermost or innermost scope.
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131229/4e040f9c/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 66, Issue 21
*****************************************