Commit 7bd8ce44 authored by Petr Pudlak's avatar Petr Pudlak Committed by Jose A. Lopes
Browse files

Improve the point-free section of the style guide



Distinguish declaring functions in the point-free style and using
a very similar technique to avoid parentheses (which isn't technically
point-free).
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent a41a1eec
...@@ -467,14 +467,25 @@ Similarly, provide Haddock-style comments for top-level definitions. ...@@ -467,14 +467,25 @@ Similarly, provide Haddock-style comments for top-level definitions.
Parentheses, point free style Parentheses, point free style
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Prefer the so-called point-free style to extra parentheses:: Prefer the so-called `point-free`_ style style when declaring functions, if
applicable::
-- bad -- bad
let a = f ( g ( h x) ) let a x = f (g (h x))
-- good
let a = f . g . h
Also use function composition in a similar manner in expressions to avoid extra
parentheses::
-- bad
f (g (h x))
-- better -- better
let b = f $ g $ h x f $ g $ h x
-- best -- best
let c = f . g . h $ x f . g . h $ x
.. _`point-free`: http://www.haskell.org/haskellwiki/Pointfree
Language features Language features
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment