template-haskell-2.5.0.0

Language.Haskell.TH.Quote

Synopsis

- data QuasiQuoter = QuasiQuoter {
  - quoteExp :: String -> Q Exp
  - quotePat :: String -> Q Pat
  - quoteType :: String -> Q Type
  - quoteDec :: String -> Q [Dec]
  }
- dataToQa :: forall a k q. Data a => (Name -> k) -> (Lit -> Q q) -> (k -> [Q q] -> Q q) -> (forall b. Data b => b -> Maybe (Q q)) -> a -> Q q
- dataToExpQ :: Data a => (forall b. Data b => b -> Maybe (Q Exp)) -> a -> Q Exp
- dataToPatQ :: Data a => (forall b. Data b => b -> Maybe (Q Pat)) -> a -> Q Pat
- quoteFile :: QuasiQuoter -> QuasiQuoter

# Documentation

data QuasiQuoter

Constructors

QuasiQuoter |

Fields

quoteExp :: String -> Q Exp
quotePat :: String -> Q Pat
quoteType :: String -> Q Type
quoteDec :: String -> Q [Dec]

dataToQa :: forall a k q. Data a => (Name -> k) -> (Lit -> Q q) -> (k -> [Q q] -> Q q) -> (forall b. Data b => b -> Maybe (Q q)) -> a -> Q q

dataToExpQ :: Data a => (forall b. Data b => b -> Maybe (Q Exp)) -> a -> Q Exp

`dataToExpQ` converts a value to a 'Q Exp' representation of the same value. It takes a function to handle type-specific cases.

dataToPatQ :: Data a => (forall b. Data b => b -> Maybe (Q Pat)) -> a -> Q Pat

`dataToPatQ` converts a value to a 'Q Pat' representation of the same value. It takes a function to handle type-specific cases.

quoteFile :: QuasiQuoter -> QuasiQuoter

`quoteFile` takes a `QuasiQuoter` and lifts it into one that read the data out of a file. For example, suppose `asmq` is an assembly-language quoter, so that you can write [asmq| ld r1, r2 |] as an expression. Then if you define `asmq_f = quoteFile asmq`, then the quote [asmq_f| foo.s |] will take input from file foo.s instead of the inline text