{-# LANGUAGE RankNTypes, ScopedTypeVariables, Safe #-}
module Language.Haskell.TH.Quote(
QuasiQuoter(..),
quoteFile,
dataToQa, dataToExpQ, dataToPatQ
) where
import Language.Haskell.TH.Syntax
import Prelude
data QuasiQuoter = QuasiQuoter {
QuasiQuoter -> String -> Q Exp
quoteExp :: String -> Q Exp,
QuasiQuoter -> String -> Q Pat
quotePat :: String -> Q Pat,
QuasiQuoter -> String -> Q Type
quoteType :: String -> Q Type,
QuasiQuoter -> String -> Q [Dec]
quoteDec :: String -> Q [Dec]
}
quoteFile :: QuasiQuoter -> QuasiQuoter
quoteFile :: QuasiQuoter -> QuasiQuoter
quoteFile (QuasiQuoter { quoteExp :: QuasiQuoter -> String -> Q Exp
quoteExp = String -> Q Exp
qe, quotePat :: QuasiQuoter -> String -> Q Pat
quotePat = String -> Q Pat
qp, quoteType :: QuasiQuoter -> String -> Q Type
quoteType = String -> Q Type
qt, quoteDec :: QuasiQuoter -> String -> Q [Dec]
quoteDec = String -> Q [Dec]
qd })
= QuasiQuoter :: (String -> Q Exp)
-> (String -> Q Pat)
-> (String -> Q Type)
-> (String -> Q [Dec])
-> QuasiQuoter
QuasiQuoter { quoteExp :: String -> Q Exp
quoteExp = (String -> Q Exp) -> String -> Q Exp
forall a. (String -> Q a) -> String -> Q a
get String -> Q Exp
qe, quotePat :: String -> Q Pat
quotePat = (String -> Q Pat) -> String -> Q Pat
forall a. (String -> Q a) -> String -> Q a
get String -> Q Pat
qp, quoteType :: String -> Q Type
quoteType = (String -> Q Type) -> String -> Q Type
forall a. (String -> Q a) -> String -> Q a
get String -> Q Type
qt, quoteDec :: String -> Q [Dec]
quoteDec = (String -> Q [Dec]) -> String -> Q [Dec]
forall a. (String -> Q a) -> String -> Q a
get String -> Q [Dec]
qd }
where
get :: (String -> Q a) -> String -> Q a
get :: (String -> Q a) -> String -> Q a
get String -> Q a
old_quoter String
file_name = do { String
file_cts <- IO String -> Q String
forall a. IO a -> Q a
runIO (String -> IO String
readFile String
file_name)
; String -> Q ()
addDependentFile String
file_name
; String -> Q a
old_quoter String
file_cts }