Indentation of If-Then-Else

kahl at kahl at
Mon Oct 23 12:18:03 EDT 2006

Henning Thielemann (haskell at henning-thielemann dot de) wrote:
 > Cale Gibbard cgibbard at, Sun Oct 22 12:23:18 EDT 2006 
 > > The 'then' and 'else' visually separate the parts of the
 > > if-expression, and serve to guide one's eyes when reading code
 > > silently, and one's words when speaking it aloud.
 > This argument is true for every function. I don't see why
 >   if test then a else b
 >     is necessary, but
 >   foldr with_function f initial_state i on_list xs
 >     not.

That's why OCaml version 3 merged in Jacques Garrigue's
labelised arguments:

ListLabels.fold_right : f:('a -> 'b -> 'b) -> 'a list -> init:'b -> 'b

This gives you even argument permutation:

let sum = fold_right ~init:0 ~f:(fun x y -> x + y)

This is a huge readability and maintainability win
for twenty-argument functions, e.g. in GUIs!

It also is a hassle to have to eta-expand pretty often
(in the presence of optional arguments,
 which are syntactic susgar for Maybe arguments)...


More information about the Haskell-prime mailing list