[Haskell-beginners] Feature request: anonymous arguments

Julius Gedvilas xged90 at gmail.com
Sat Aug 30 09:32:10 UTC 2014


0. And more specific functions hopefully has more specific types, which
even more reduce a need for an extra name in a namespace.

1. I do not suggest to replace named arguments entirely. Anonymous
functions more so does not replace their named counterparts, but find their
place in a language (... in the logo (\);).

2. Adding parameters is a sub-process of a larger refactoring rather then
an "edit on the fly", or so do I think ...

3. Is it? *GHCi *does not recognize it.

4. It is shorter, but most important it does reduce number of useless
things (like one letter arg names), for benefit of both writer and reader
(and compiler).


On Sat, Aug 30, 2014 at 11:31 AM, Karl Voelker <karl at karlv.net> wrote:

>  On Sat, Aug 30, 2014, at 12:21 AM, Julius Gedvilas wrote:
>
> Anonymous argument (AA) is an argument without a name.
>
> w/o AA:
> func :: a -> a -> a -> a
> func aa0 aa1 aa2 = aa0 `op` aa1 `op` aa2
> \aa0 aa1 aa2 -> aa0 `op` aa1 `op` aa2
>
> w/ AA:
> func :: a -> a -> a -> a
> func = \0 `op` \1 `op` \2
> \-> \0 `op` \1 `op` \2
>
>
> I think you have identified a real problem - sometimes, our functions are
> so abstract that it is difficult to name the parameters.
>
> That said, I can think of a few cons to your proposal:
>
> 1. With lexically nested functions, you lose the ability to refer to
> arguments of the outer function inside the inner function if both functions
> use AA.
>
> 2. If you add a new parameter to a function anywhere other than at the
> end, the effective "names" of all the following parameters change. This is
> especially dangerous if many of the parameters have the same types, since
> you could easily fail to update some of the references to those arguments,
> and your function would still
>
> 3. Reusing the backslash is not so simple. For example, "\0 -> 1" is a
> syntactically valid function in Haskell already.
>
> 4. It's not really any shorter than the alternative, which is to just use
> very short variable names.
>
> -Karl
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140830/5dac41f5/attachment-0001.html>


More information about the Beginners mailing list