Generalize compileError into Quasi constraint.

This commit is contained in:
Kei Hibino 2014-10-09 14:56:44 +09:00
parent 28fe9efeb5
commit a5dd1c86ed

View File

@ -25,13 +25,12 @@ module Language.Haskell.TH.Lib.Extra (
) where
import Language.Haskell.TH
(Ppr, ppr, Q, runQ, runIO,
(Ppr, ppr, Q, runQ,
Name, Dec, sigD, valD, TypeQ, varP, normalB,
ExpQ, litE, integerL)
import Language.Haskell.TH.PprLib (Doc)
import Language.Haskell.TH.Syntax (Quasi)
{- $extraTemplateFunctions
Extra functions to generate haskell templates.
-}
@ -65,9 +64,10 @@ which generating haskell templates.
-}
-- | Raise compile error from TH code.
compileError :: String -> Q a
compileError = runIO . compileErrorIO
compileError :: Quasi m => String -> m a
compileError = runQ . fail
-- | 'IO' version of 'compileError'.
compileErrorIO :: String -> IO a
compileErrorIO = ioError . userError
compileErrorIO = compileError
{-# DEPRECATED compileErrorIO "Use compileError instead of this" #-}