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