Proposal: require spaces around the dot operator

Cale Gibbard cgibbard at gmail.com
Mon Feb 13 00:18:54 CET 2012


On 12 February 2012 18:00, Evan Laforge <qdunkan at gmail.com> wrote:
> On Thu, Feb 9, 2012 at 6:11 PM, Greg Weber <greg at gregweber.info> wrote:
>> Similar to proposal #20, which wants to remove it, but immediately
>> less drastic, even though the long-term goal is the same.
>> This helps clear the way for the usage of the unspaced dot as a record
>> field selector as shown in proposal #129.
>
> I'm hoping the eventual resolution for the whole record thing doesn't
> involve dots, rather, that it does but is using them for composition.
> So I don't want to support something that will break hundreds of lines
> of code (I often use dot without spaces) for the sake of maybe
> supporting something I think there are better solutions to in the
> first place!
>
> What's more, if records use dot as composition then not only do we not
> need to worry about breaking tons of code and what meaning to give to
> (.f) and (f.) sections, but I'll use even more space-less dots, to
> compose together record labels :)

I agree with this. In reading over this discussion, I have often
wondered how people seem to have forgotten that *to Haskell
programmers* the dot means composition. We shouldn't worry so much
about how Java programmers read Haskell code, because obviously,
syntax is not the biggest hurdle to their understanding it anyway. We
should be concerned with how the people who are using Haskell every
day read the dot.

Sure, dot is also in the syntax for module selection, but at least for
my part I find even that much painful. I specifically go out of my way
to avoid using module qualifiers whenever possible because it looks
like composition and makes expressions hard to read. I will append
abbreviations of the module name to identifiers if I think that they
will conflict with other exports in the same project. I would avoid
using records because of it, and where I couldn't do so, I would end
up writing wrapper functions around field selections just to avoid
using dots for something other than composition. That would be sad, I
think. Almost any other string of symbol characters would be less
painful. Composition is by a good margin my most used infix operator,
and should be pretty common, I think, in any functional programmer's
code. Not only that, but dot is a *good* notation for it. It's
visually quiet, and it's easy to type on every keyboard/terminal
combination in existence.

By comparison, record selection is a far less important operation and
can be given a less pretty name. Personally, just using a prefix
(named) function to select a field seems completely adequate to me,
but we could invent some other string of symbols for people who want
to write it infix. Or, just an idea, recordValue{fieldName} could
translate into whatever function is used to select the field,
mimicking construction syntax.

 - Cale



More information about the Haskell-prime mailing list