Improve Template Haskell error recovery
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
Trac metadata
Trac field | Value |
---|---|
Version | 6.8.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | marco-oweber@gmx.de |
Operating system | Unknown |
Architecture | Unknown |