Skip to content

Commit

Permalink
small edit to article
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Hannan committed Jul 18, 2011
1 parent 82a846e commit a1ed175
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc/Article2.md
Expand Up @@ -54,7 +54,7 @@ Stepping through the execution on a small list shows an unevaluated expression b
=> 3 + 3
=> 6

This is not good and unexpected. How can you detect these problems without analyzing every expression for unevaluated expression build up? The answer is: [profile](http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/profiling.html) your application if it is not performing as expected. It will tell you how much time and space different functions are consuming. Once you find the troublesome code, the solution is easy: Force the evaluation of the unevaluated expression by marking it as *strict* (*eager*). This is done by prefixing its variable with `!` and adding language extension [*BangPatterns*](http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/bang-patterns.html).
This is not good and unexpected. Fortunately, many of these problems may be recognized by the compiler's [strictness analyzer](http://www.haskell.org/haskellwiki/GHC_optimisations#Strictness_analysis) and fixed automatically. However, it is not guaranteed. So how can you detect these problems without analyzing every expression for unevaluated expression build up? The answer is: [profile](http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/profiling.html) your application if it is not performing as expected. It will tell you how much time and space different functions are consuming. Once you find the troublesome code, the solution is easy: Force the evaluation of the unevaluated expression by marking it as *strict* (*eager*). This is done by prefixing its variable with `!` and adding language extension [*BangPatterns*](http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/bang-patterns.html).

{-# LANGUAGE BangPatterns #-}
reduce op id list = red id list where red !acc list = case list of [] -> acc; head:tail -> red (head `op` acc) tail
Expand Down

0 comments on commit a1ed175

Please sign in to comment.