Use a per-session data structure for callbacks. Make 'WarnErrLogger'
authorThomas Schilling <nominolo@googlemail.com>
Fri, 28 Nov 2008 10:36:28 +0000 (10:36 +0000)
committerThomas Schilling <nominolo@googlemail.com>
Fri, 28 Nov 2008 10:36:28 +0000 (10:36 +0000)
commit9a4607c35c107bca78f08f7e57896044c66118be
tree5ed585adcca0efa135c9059ed44b1625bfe7a823
parent41fd413684f4dba0259fefffa41c9c9eac2f629a
Use a per-session data structure for callbacks.  Make 'WarnErrLogger'
part of it.

Part of the GHC API essentially represents a compilation framework.
The difference of a *framework* as opposed to a *library* is that the
overall structure of the functionality is pre-defined but certain
details can be customised via callbacks.  (Also known as the Hollywood
Principle: "Don't call us, we'll call you.")

This patch introduces a per-session data structure that contains all
the callbacks instead of adding lots of small function arguments
whenever we want to give the user more control over certain parts of
the API.  This should also help with future changes: Adding a new
callback doesn't break old code since code that doesn't know about the
new callback will use the (hopefully sane) default implementation.

Overall, however, we should try and keep the number of callbacks small
and well-defined (and provide useful defaults) and use simple library
routines for the rest.
compiler/main/GHC.hs
compiler/main/HscMain.lhs
compiler/main/HscTypes.lhs
ghc/Main.hs