3 ms·
My rule has been to just pad "do" appropriately. Almost everything else works out well with a 4-space tab. Also, don't ever use only one-or-two spaces for ind
by Periodic 16y ago
My rule has been to just pad "do" appropriately. Almost everything else works out well with a 4-space tab. Also, don't ever use only one-or-two spaces for indentation, and if you're finding you have a long expression with so much indentation and unindentation that it gets confusing I usually find I'm doing something confusing and should simplify it anyway. For example:
let x = y
in do something
something with
( lots
. of
. args
)
something else
Is not that hard to read for me, and actually looks quite nice.
And if you're getting those terribly long-expressions, break them up. They can always be broken out in a let expression to be simpler, and with let the precedence is obvious.
map (alpha . bravo) . filter charlie <$> xray <|> yankee >> zulu
might be better written as
let f1 = map (alpha . bravo) . filter charlee <$> xray
f2 = yankee
result = f1 <|> f2
in result >> zulu
Haskell has the ability to write great one-liners, just like Perl, but it takes discipline not to use them.
Of course naming your variables descriptively helps a lot too. Examples with single-variable names are probably not the best.
- eru 16y agoYes, but like in Lisp, your Haskell code looks usually better without trailing parens.