diff options
-rw-r--r-- | docs/users_guide/hints.rst | 14 |
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 |