Proposal: Dot as Postfix Function Apply

David Feuer david.feuer at gmail.com
Thu Nov 5 01:24:38 UTC 2015


The library committee does not generally have any formal authority over or
involvement in language extensions or language changes. I would argue this
entire discussion should probably have taken place elsewhere (e.g.,
haskell-cafe or ghc-devs). That said, the library gurus likely do have some
sense of how much you're likely to gain by adding such an extension.

While I'm writing this message, I think I might as well try to explain a
bit better why I think the proposed extension is a bad idea. In a
procedural language, the field dot is an all-purpose way to narrow focus
from a record or object to a field or method. In C, the following all make
sense (I think--my C is rusty).

foo = fish.dog (fish.cat) + 4
fish.cat = 12
fish.cat += 17
shark = &fish.cat

In Haskell, only the first usage is sensible. Once the hypothetical .cat is
applied, the fish is out of the picture. Lenses, on the other hand, offer
sensible ways to talk about functional approximations of all of these
things. I believe a syntactic extension making lenses easier to use could
be a big win, but the current proposal just makes easy things easy, which
they already are.

Others have, correctly, mentioned the use of . in the module system as
justification. This is sensible, since modules look a bit like records if
you squint enough. But I think most Haskellers will agree that they'd
rather see modules look more like records than the other way around.
On Nov 4, 2015 7:20 PM, "Greg Weber" <greg at gregweber.info> wrote:

> +1 for an opt-in extension. I am not sure if any approval is needed from
> the libraries committee for an optional extension like this if you are
> willing to do the work to bring it to fruition yourself.
>
> On Wed, Nov 4, 2015 at 2:44 AM, Jeremy <voldermort at hotmail.com> wrote:
>
>> Dot as Postfix Function Apply
>> (
>> https://ghc.haskell.org/trac/ghc/wiki/Records/DeclaredOverloadedRecordFields/DotPostfix
>> )
>> was originally part of ORF, but dropped to keep the scope/discussion more
>> manageable. Now that ORF is in for GHC 8.0, I would like to re-propose dot
>> postfix syntax.
>>
>> The idea is that instead of
>>
>> (title person) ++ " " ++ (firstName person) ++ " " ++ (lastName person)
>>
>> we could have
>>
>> person.title ++ " " ++ person.firstName ++ " " ++ person.lastName
>>
>> This is a simple source-to-source translation with no changes to the type
>> system (TDNR is an orthogonal proposal). The advantages are:
>>
>>   1. Code that's easier to read/write.
>>   2. Familiar to users of almost every other programming language.
>>   3. IDE auto-complete - an IDE can suggest functions applicable to the
>> variable after typing .
>>
>> This would be an opt-in extension.
>>
>> I'm posting this to the libraries list because that's where proposals
>> generally go, although this isn't strictly a library issue. If it should
>> be
>> on a different list I'll move it.
>>
>>
>>
>> --
>> View this message in context:
>> http://haskell.1045720.n5.nabble.com/Proposal-Dot-as-Postfix-Function-Apply-tp5821620.html
>> Sent from the Haskell - Libraries mailing list archive at Nabble.com.
>> _______________________________________________
>> 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/e9bd18c5/attachment.html>


More information about the Libraries mailing list