Opened 9 years ago

Last modified 21 months ago

#2340 new feature request

Improve Template Haskell error recovery

Reported by: simonpj Owned by:
Priority: lowest Milestone:
Component: Template Haskell Version: 6.8.2
Keywords: Cc: marco-oweber@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

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

Change History (17)

comment:1 Changed 9 years ago by fons

Component: CompilerTemplate Haskell

comment:2 Changed 9 years ago by igloo

Milestone: 6.10.1

comment:3 Changed 9 years ago by igloo

Milestone: 6.10.16.12 branch

comment:4 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:5 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:6 Changed 7 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:7 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:8 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:9 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:10 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:11 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:12 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:13 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:14 Changed 3 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:15 Changed 3 years ago by thoughtpolice

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:16 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:17 Changed 21 months ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.