module Text.Here (here, there) where
import Language.Haskell.TH
( litE
, stringL
)
import Language.Haskell.TH.Quote
( QuasiQuoter
( QuasiQuoter
, quoteExp
, quotePat
, quoteType
, quoteDec
)
, quoteFile
)
err :: String -> String
err ctx =
"You have used the `here` QuasiQuoter in a " ++ ctx ++ " context; " ++
"you must only use it as a string literal expression"
here :: QuasiQuoter
here = QuasiQuoter
{ quoteExp = litE . stringL
, quotePat = const $ error $ err "pattern"
, quoteType = const $ error $ err "type"
, quoteDec = const $ error $ err "declaration"
}
there :: QuasiQuoter
there = quoteFile here