Proposal: Dot as Postfix Function Apply

Mike Meyer mwm at mired.org
Wed Nov 4 21:09:05 UTC 2015


On Wed, Nov 4, 2015 at 2:41 PM Dan Burton <danburton.email at gmail.com> wrote:

> +1, it's no worse than module syntax, and it's opt-in.
>
> I suppose my vote bumps it up from -1000 to -999. /shrug
>
> Dot as postfix function application is frankly a great idea that exists in
> many many languages. It's great for intellisense and it's often great for
> reading code left to right. It may not be the best fit for Haskell, but
> Haskell has never been one of those "one right way to code" sort of
> languages.
>

This isn't about dot as postfix function application. You can already do
that:

import Prelude hiding ((.))

a . f = f a

main = 23 . print

This is about changing the syntax of the language to make it more
comfortable to people coming from OO languages, in particular mimicking the
way most of those languages select features from an object. The syntax
change is making dot without spaces bind tighter than function application
so you can say "print object.element" instead of having to say print
(element object)" or "print $ element object".

Alexander Berntsen suggested adding a new fixity so you could declare
operators that bind tighter than function application. That would let you
write "print object . element" by declaring the fixity of "." to be that
new fixity. Since such a change doesn't break any existing code, it doesn't
need to be an extension that's enabled. It's a need I've felt every so
often myself.

-1. Once you get past wanting to write OO code in Haskell, this itch should
go away. I think it would be like all the "OO in haskell" libraries that
newcomers write, then quit using once they get past that desire.

At the very least, make this a general change, so that name<op>name without
spaces binds tighter than functions, so it's useful for more than writing
code that looks like Pyhton/C/C++/etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20151104/6d237ce1/attachment.html>


More information about the Libraries mailing list