Proposal: Dot as Postfix Function Apply

Dan Burton danburton.email at gmail.com
Wed Nov 4 20:44:46 UTC 2015


>
> Is it confusing to newcomers that (.) doesn't bind tighter than ' ' in
> haskell? Sure. But causing that to randomly change back and forth is more
> confusing still.


It already does randomly change back and forth though, due to module
syntax. With the proposed option turned on, the change seems *less* random
to me, being solely based on whitespace and not *also* based on whether the
LHS is a module name.

-- Dan Burton

On Wed, Nov 4, 2015 at 12:20 PM, Edward Kmett <ekmett at gmail.com> wrote:

> Precedence and syntax in a language tells you a lot about what the
> language considers important. We take the 'quietest' syntax for things that
> we want to have fade into the background. Whitespace and periods are both
> very quiet syntax.
>
> In math ' ' is often multiplication, in the lambda calculus it is function
> application.
>
> We choose ' ' to have the tightest precedence in Haskell in a way that
> nicely emphasizes the importance of functions here. Admittedly we already
> have two awkward exceptions there that routinely throw folks for loops. @
> syntax in patterns and the {}'s used by record syntax both bind tighter
> than whitespace application.
>
> We choose . for function composition a.) because it on the keyboard and
> again, it emphasizes the importance of functions. Functions compose and you
> can make more interesting things out of the parts, the field accessor
> syntax you propose here does not compose particularly well.
>
> With other solutions available today that this proposal actively makes
> worse, I can both read and write back to those fields
>
> You're asking for (.), one of the most common symbols in Haskell code
> today to take on another meaning, furthering confusion for its current
> standard role, for it to effectively alternate binding looser than ' ' when
> you put spaces around it to tighter than ' ' when you don't while
> simultaneously changing semantics entirely.
>
> Is it confusing to newcomers that (.) doesn't bind tighter than ' ' in
> haskell? Sure. But causing that to randomly change back and forth is more
> confusing still.
>
> -Edward
>
> On Wed, Nov 4, 2015 at 2:40 PM, Harry . <voldermort at hotmail.com> wrote:
>
>> When you consider that every other programming language in common use
>> (and almost every language not in common use as well) allows you to write:
>>
>> print person.name
>>
>> while Haskell requires something like:
>>
>> print (person & name) or
>>
>> print $ person.^name
>>
>> and even that after importing a third-party library or defining it
>> yourself, you begin to understand why beginners think that Haskell looks
>> more like Japanese emoticons than programming.
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20151104/533251a0/attachment.html>


More information about the Libraries mailing list