#2340: Improve Template Haskell error recovery
--------------------------------+-------------------------------------------
    Reporter:  simonpj          |       Owner:         
        Type:  feature request  |      Status:  new    
    Priority:  normal           |   Milestone:         
   Component:  Compiler         |     Version:  6.8.2  
    Severity:  normal           |    Keywords:         
  Difficulty:  Unknown          |    Testcase:         
Architecture:  Unknown          |          Os:  Unknown
--------------------------------+-------------------------------------------
 Marc Weber wants better error recovery in TH's Q monad:
 http://www.haskell.org/pipermail/template-haskell/2008-May/000666.html

 The Quasi monad is defined thus:
 {{{
 class (Monad m, Functor m) => Quasi m where
         -- Fresh names
   qNewName :: String -> m Name

         -- Error reporting and recovery
   qReport  :: Bool -> String -> m ()    -- Report an error (True) or
 warning (False)
                                         -- ...but carry on; use 'fail' to
 stop
   qRecover :: m a -> m a -> m a         -- Recover from the monadic 'fail'
                                         -- The first arg is the error
 handler

         -- Inspect the type-checker's environment
   qReify :: Name -> m Info
   qLocation :: m Loc

         -- Input/output (dangerous)
   qRunIO :: IO a -> m a
 }}}
 A sensible change (but it would be a change) would be to change `qRecover`
 thus:
 {{{
   qRecover :: m a -> ([(Bool,String)] -> m a) -> m a
   -- (qRecover q f) runs the action `q`, collecting all the messages
   -- emitted by `qReport`.  If the action `q` calls the monad `fail`,
   -- these messages are passed to `f`.  If the action `q` does not call
   -- `fail`, the messages are retained in the monad, just as if the
   -- `qRecover` was not there.
 }}}
 Comments?  This would be quite easy to implement in 6.10.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2340>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to