Commit eea5e916 authored by Petr Pudlak's avatar Petr Pudlak

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 b18409cf
......@@ -467,14 +467,25 @@ Similarly, provide Haddock-style comments for top-level definitions.
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
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
let b = f $ g $ h x
f $ g $ h x
-- best
let c = f . g . h $ x
f . g . h $ x
.. _`point-free`: http://www.haskell.org/haskellwiki/Pointfree
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