
Peter Hercek wrote:
Jules Bean wrote:
I have no idea what you're talking about. It works fine on multiple lines:
f x = g . transform displacement . scale factor $ x
is perfectly valid.
Yes, it is. It is not an issue if you prefer to indent based on previous line instead of "always by the same small amount of spaces". And then problem happens when the amount of spaces is less than 5. E.g. this does not work:
h x = x f x = let g x = h . (+ 5) . (* 2) $ x in g x
Indeed, no, but this does: h x = x f x = let {g x = h . (+ 5) . (* 2) $ x} in g x In other words, if you don't like the layout conventions of layout style, then don't use layout style.
I do not like to indent based on previous lines since it should be re-indented when the previous lines change (e.g. because of identifier rename).
I can't say that's ever bothered me very much, but I agree it is a minor annoyance. It is made fairly painless by a decent editor.
So I indent based on previous lines only when it adds a LOT to readability. Of course fixed amount indentation by big enough number of spaces would do but then your code gets too wide if more blocks are nested and I like to be withing 110 chars at worst (preferably 80).
I certainly try to keep my lines narrow, (normally under 80) but I've never found any trouble doing that. I don't tend to nest very deeply.
This is probably not a problem for "where" keyword then the next longest from the "let", "where", "do", "of" set is "let" which would mean that 5 should be enough, not that bad, but looks much for me. Other option is to leave "let" keyword alone on the line and then indent "g x" by one and the function body by two indentation units from the "let" keyword. So from my point of view the point free style is great if it fits on one line well ... otherwise it depends.
I think thinking of 'indentation units' is a bit harmful in layout code, for roughly the reasons you describe. I would suggest either use layout (and indent at the places that layout suggests you should), or don't use layout (use {} like C or Perl). Jules