summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Abel <andreas.abel@ifi.lmu.de>2021-08-20 17:01:13 +0200
committerZubin Duggal <zubin.duggal@gmail.com>2021-10-12 14:54:34 +0530
commit49acdc6d5695e02ebd56ce2f4a3b58086b33963a (patch)
treebd9dffb698bd68515fbc415d41eb028a096b6289
parent552235e24a3c1d80d508fea1f9c3fa70953390f3 (diff)
downloadhaskell-49acdc6d5695e02ebd56ce2f4a3b58086b33963a.tar.gz
Doc fix #20259: suggest bang patterns instead of case in hints.rst
(cherry picked from commit c040753820e540663ef74e63f15c42cc2996c19d)
-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 cdec6a4f4c..94fc748e86 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