• Thomas Schilling's avatar
    Use 'GhcMonad' in GHC and split up checkModule into phases. · 1c7d0ac0
    Thomas Schilling authored
    I'm not sure I covered all the ways of throwing errors in the code.
    Some functions throw ProgramErrors, some error messages.  It's still
    quite a mess, but we're getting closer.  The missing cases are mostly
    errors that cannot be fixed by the API client either or are a result
    of wrong usage, so are in any case fatal.
    
    One function, 'getModuleInfo', still returns a 'Maybe', but the
    documentation suggests it should always succeed.  So I may change that
    soon.
    
    The spit-up of of 'checkModule' has pros and cons.  The various forms
    of 'checkModule*' now become:
    
     checkAndLoadModule ms False ~~>
        loadModule =<< typecheckModule =<< parseModule (ms_mod_name ms)
    
     checkAndLoadModule ms True ~~>
       loadModule =<< desugarModule =<< typecheckModule =<< parseModule (ms_mod_name ms)
    
     checkModule mn False ~~>
       typecheckModule =<< parseModule mn
    
     checkModule mn True ~~>
       desugarModule =<< typecheckModule =<< parseModule mn
    
    The old APIs cannot easily be provided, since the result type would be
    different depending on the second argument.  However, a more
    convenient API can be modelled on top of these four functions
    ({parse,typecheck,desugar,load}Module).
    1c7d0ac0
GHC.hs 90.9 KB