Revision 7bd8ce44
b/doc/dev-codestyle.rst | ||
---|---|---|
467 | 467 |
Parentheses, point free style |
468 | 468 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
469 | 469 |
|
470 |
Prefer the so-called point-free style to extra parentheses:: |
|
470 |
Prefer the so-called `point-free`_ style style when declaring functions, if |
|
471 |
applicable:: |
|
471 | 472 |
|
472 | 473 |
-- bad |
473 |
let a = f ( g ( h x) ) |
|
474 |
let a x = f (g (h x)) |
|
475 |
-- good |
|
476 |
let a = f . g . h |
|
477 |
|
|
478 |
Also use function composition in a similar manner in expressions to avoid extra |
|
479 |
parentheses:: |
|
480 |
|
|
481 |
-- bad |
|
482 |
f (g (h x)) |
|
474 | 483 |
-- better |
475 |
let b = f $ g $ h x
|
|
484 |
f $ g $ h x |
|
476 | 485 |
-- best |
477 |
let c = f . g . h $ x |
|
486 |
f . g . h $ x |
|
487 |
|
|
488 |
.. _`point-free`: http://www.haskell.org/haskellwiki/Pointfree |
|
478 | 489 |
|
479 | 490 |
Language features |
480 | 491 |
~~~~~~~~~~~~~~~~~ |
Also available in: Unified diff