[Haskell-cafe] Re: let and fixed point operator

Peter Hercek peter at syncad.com
Mon Sep 3 09:54:08 EDT 2007


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

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). 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).
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.

Thanks,
    Peter.



More information about the Haskell-Cafe mailing list