Use 'GhcMonad' in GHC and split up checkModule into phases.
authorThomas Schilling <nominolo@googlemail.com>
Sun, 14 Sep 2008 23:20:44 +0000 (23:20 +0000)
committerThomas Schilling <nominolo@googlemail.com>
Sun, 14 Sep 2008 23:20:44 +0000 (23:20 +0000)
commit1c7d0ac0a433f85effeb5e9cfb6b303c26b201d1
tree058276f91df5d23b000007b71e0aded5dea25303
parent3a61d75c70f61a2b919e94e85ffe1166e7151b5b
Use 'GhcMonad' in GHC and split up checkModule into phases.

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).
compiler/main/GHC.hs