[Haskell-cafe] accessible layout proposal?

Daniel Fischer daniel.is.fischer at web.de
Tue Sep 22 21:32:56 EDT 2009

Am Mittwoch 23 September 2009 02:51:59 schrieb Jimmy Hartzell:
> > On Sep 22, 2009, at 8:01 PM, Jimmy Hartzell wrote:
> >> I am in love with this proposal:
> >> http://www.haskell.org/haskellwiki/Accessible_layout_proposal
(Richard O'Keefe:)
> >
> > I hadn't read it before.  Now that I have, I really do not like
> > it.  "Syntactic sugar causes cancer of the semicolon" as Alan
> > Perlis once said, and to my taste this proposal definitely
> > counts as cancer of the semicolon.  In effect, its purpose
> > is to overload vertical white space.
> >
> > Any time that you have something where you think you need
> > this, it's likely that a better solution is to break what
> > you are doing into smaller pieces.

I don't like it either. I have not nearly a s strong feelings as Mr. O'Keefe, but to me it 
doesn't look right.

> Well, look at code like this:
> wrapParens str = concat [
>    "(",
>    str,
>    ")"
>   ]
> (And yes, I realize you can do something like this with 'printf "(%s)"
> str'.)

Or, what I do:

    [ "("
    , str
    , ")"

(of course, here I would just write '(' : str ++ ")"). I admit it looked odd for the first 
couple of hours, but now I find it nice, clean and systematic.

> First off, there is a serious issue with the commas. You should at least
> be allowed to have a comma after the last element, a la Python. Otherwise,
> the last one is randomly special in this list, and in a format like this,
> I regularly edit code accidentally leaving off commas, yielding stuff
> like:
> concat [
>    "(",
>    str,
>    ")"     -- (oops, no comma!)
>    lineEnd -- forgot I needed this
> ]

And that is avoided, because a missing comma leaps to the eye.

> which (of course) results in a very confusing type error. Meanwhile, you
> have to format your code very awkwardly, as the closing bracket can't be
> in the left-most column,

Which is a good thing in my eyes.

> In summary, I have to spend a good portion of my time coding Haskell
> dealing with the fact that I have a lot of {'s, ['s, and ,'s to keep track
> of, and they rarely fit on one line (records, ADTs, lists). I have to
> spend a significant amount of my coding time finagling the layout to look
> sensible, and I don't think anyone would claim that I just shouldn't use
> records or ADTs.

I see your point but remain not liking the proposal.

More information about the Haskell-Cafe mailing list