Changes between Version 14 and Version 15 of Commentary/Compiler/API
- Timestamp:
- 10/02/06 05:31:00 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Commentary/Compiler/API
v14 v15 14 14 15 15 * You probably want to wrap the whole program in {{{defaultErrorHandler defaultDynFlags}}} to get error messages 16 * Initialize the GHC top dir: {{{init}}}17 16 * Create a new session: {{{newSession}}} 17 * Set the flags: {{{getSessionDynFlags}}}, {{{setSessionDynFlags}}}. 18 18 * Add some ''targets'': {{{setTargets}}}, {{{addTarget}}}, {{{guessTarget}}} 19 19 * Perform [[ref(Dependency Analysis)]]: {{{depanal}}} … … 29 29 30 30 main = defaultErrorHandler defaultDynFlags $ do 31 GHC.init (Just "/usr/local/lib/ghc-6.5") -- or your build tree! 32 s <- newSession mode 31 s <- newSession mode (Just "/usr/local/lib/ghc-6.5") 33 32 flags <- getSessionDynFlags s 34 33 (flags, _) <- parseDynamicFlags flags [] 35 34 GHC.defaultCleanupHandler flags $ do 36 flags <- initPackages flags 37 setSessionDynFlags s flags 35 setSessionDynFlags s flags{ hscTarget=HscInterpreted } 38 36 -- your code here 39 37 }}} 38 39 You must pass the path to {{{package.conf}}} as an argument to {{{newSession}}}. 40 41 The {{{hscTarget}}} field of {{{DynFlags}}} tells the compiler what kind of output to generate from compilation. There is unfortunately some overlap between this and the {{{GhcMode}}} passed to {{{newSession}}}; we hope to clean this up in the future, but for now it's probably a good idea to make sure that these two settings are consisent. That is, if {{{mode==Interactive}}}, then {{{hscTarget==Interpreted}}}, if {{{mode==JustTypecheck}}} then {{{hscTarget==HscNothing}}}. 40 42 41 43 == Targets ==
