Changes between Version 14 and Version 15 of Commentary/Compiler/API


Ignore:
Timestamp:
Oct 2, 2006 12:31:00 PM (9 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/API

    v14 v15  
    1414
    1515 * You probably want to wrap the whole program in {{{defaultErrorHandler defaultDynFlags}}} to get error messages
    16  * Initialize the GHC top dir: {{{init}}}
    1716 * Create a new session: {{{newSession}}}
     17 * Set the flags: {{{getSessionDynFlags}}}, {{{setSessionDynFlags}}}.
    1818 * Add some ''targets'': {{{setTargets}}}, {{{addTarget}}}, {{{guessTarget}}}
    1919 * Perform [[ref(Dependency Analysis)]]: {{{depanal}}}
     
    2929
    3030main = 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")
    3332  flags <- getSessionDynFlags s
    3433  (flags, _) <- parseDynamicFlags flags []
    3534  GHC.defaultCleanupHandler flags $ do
    36     flags <- initPackages flags
    37     setSessionDynFlags s flags
     35    setSessionDynFlags s flags{ hscTarget=HscInterpreted }
    3836    -- your code here
    3937}}}
     38
     39You must pass the path to {{{package.conf}}} as an argument to {{{newSession}}}. 
     40
     41The {{{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}}}.
    4042
    4143== Targets ==