summaryrefslogtreecommitdiff
path: root/ghc/Main.hs
diff options
context:
space:
mode:
authorThomas Schilling <nominolo@googlemail.com>2008-11-28 10:36:28 +0000
committerThomas Schilling <nominolo@googlemail.com>2008-11-28 10:36:28 +0000
commit9a4607c35c107bca78f08f7e57896044c66118be (patch)
tree5ed585adcca0efa135c9059ed44b1625bfe7a823 /ghc/Main.hs
parent41fd413684f4dba0259fefffa41c9c9eac2f629a (diff)
downloadhaskell-9a4607c35c107bca78f08f7e57896044c66118be.tar.gz
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.
Diffstat (limited to 'ghc/Main.hs')
-rw-r--r--ghc/Main.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 06a5cebd92..df90857fbb 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -16,7 +16,8 @@ module Main (main) where
import qualified GHC
import GHC ( DynFlags(..), HscTarget(..),
GhcMode(..), GhcLink(..),
- LoadHowMuch(..), dopt, DynFlag(..) )
+ LoadHowMuch(..), dopt, DynFlag(..),
+ defaultCallbacks )
import CmdLineParser
-- Implementations of the various modes (--show-iface, mkdependHS. etc.)
@@ -515,7 +516,7 @@ doMake srcs = do
doShowIface :: DynFlags -> FilePath -> IO ()
doShowIface dflags file = do
- hsc_env <- newHscEnv dflags
+ hsc_env <- newHscEnv defaultCallbacks dflags
showIface hsc_env file
-- ---------------------------------------------------------------------------