Performance/Modules

From HaskellWiki
< Performance
Revision as of 11:32, 13 January 2007 by Quale (talk | contribs) (+cat)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Haskell Performance Resource

Constructs:
Data Types - Functions
Overloading - FFI - Arrays
Strings - Integers - I/O
Floating point - Concurrency
Modules - Monads

Techniques:
Strictness - Laziness
Avoiding space leaks
Accumulating parameter

Implementation-Specific:
GHC - nhc98 - Hugs
Yhc - JHC

Use an explicit export list

(note: this only applies to compilers based on separate compilation like GHC, not to those based on whole-program compilation like JHC).

If you do not have an explicit export list in a module, the compiler must assume that everything in that module will be exported. This disables various useful optimisations:

  • If a function is used only once in the current module, and not exported, there is no penalty for inlining the function at its single use point.
  • If a function is not used at all, and not exported, its definition can be discarded.
  • The compiler has more flexibility regarding calling conventions and the like for functions that are not visible beyond the current compilation unit.