
#11661: Missing MonadFail instance for Q monad from TemplateHaskell -------------------------------------+------------------------------------- Reporter: PeterTrsko | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): `fail :: String -> Q a` is the standard way for Template Haskell code to report a fatal error. (Say you are writing a quasiquoter for regular expressions, and the regular expression is ill-formed.) See http://hackage.haskell.org/package/template-haskell-2.10.0.0/docs /Language-Haskell-TH.html#v:reportError. `error :: String -> Q a` also works, sort of. But the error is reported differently by GHC ("Exception when trying to run compile-time code:"). `recover :: Q a -> Q a -> Q a` recovers from `fail`, but obviously not `error`. I don't know whether anyone actually uses `recover` though. I don't really understand all the issues around this `MonadFail` stuff but `Q`'s `fail` isn't something we should just sweep under the rug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11661#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler