summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAndreas Abel <andreas.abel@ifi.lmu.de>2021-08-20 17:01:13 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-08-23 13:36:38 -0400
commitc040753820e540663ef74e63f15c42cc2996c19d (patch)
tree8dc326d452bee2882234bce795f079bc610e985d /docs
parentf3892b5f57b5a75c20eb12a45575a15b2a3dfd3f (diff)
downloadhaskell-c040753820e540663ef74e63f15c42cc2996c19d.tar.gz
Doc fix #20259: suggest bang patterns instead of case in hints.rst
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/hints.rst14
1 files changed, 4 insertions, 10 deletions
diff --git a/docs/users_guide/hints.rst b/docs/users_guide/hints.rst
index 5cb171ff69..ea7ff0e9fb 100644
--- a/docs/users_guide/hints.rst
+++ b/docs/users_guide/hints.rst
@@ -172,23 +172,17 @@ Strict functions are your dear friends:
The former will result in far better code.
- A less contrived example shows the use of ``cases`` instead of
+ A less contrived example shows the use of ``BangPatterns`` on
``lets`` to get stricter code (a good thing):
::
- f (Wibble x y) # beautiful but slow
+ f (Wibble x y)
= let
- (a1, b1, c1) = unpackFoo x
- (a2, b2, c2) = unpackFoo y
+ !(a1, b1, c1) = unpackFoo x
+ !(a2, b2, c2) = unpackFoo y
in ...
- f (Wibble x y) # ugly, and proud of it
- = case (unpackFoo x) of { (a1, b1, c1) ->
- case (unpackFoo y) of { (a2, b2, c2) ->
- ...
- }}
-
GHC loves single-constructor data-types:
It's all the better if a function is strict in a single-constructor
type (a type with only one data-constructor; for example, tuples are