Safe Haskell | None |
---|
Language.Haskell.AntiQuoter.Combinators
Contents
Description
Several combinators for AntiQuoters
, mainly EP
related.
- varQ :: EP q => Name -> Q q
- conQ :: EP q => Name -> [Q q] -> Q q
- litQ :: EP q => Lit -> Q q
- tupQ :: EP q => [Q q] -> Q q
- listQ :: EP q => [Q q] -> Q q
- ignore :: AQResult q
- ignorePat :: EP q => AQResult Exp -> AQResult q
- onlyExp :: EP q => AQResult Exp -> AQResult q
- ignoreExp :: EP q => AQResult Pat -> AQResult q
- onlyPat :: EP q => AQResult Pat -> AQResult q
- splice :: EP q => String -> Q q
- wild :: EP q => Q Exp -> Q q
- nonsenseP :: EP q => String -> AQResult Exp -> AQResult q
- nonsenseE :: EP q => String -> AQResult Pat -> AQResult q
Lifted constructors.
Ignoring
ignorePat :: EP q => AQResult Exp -> AQResult qSource
Yielding only a result for expressions and ignoring in patterns.
onlyExp :: EP q => AQResult Exp -> AQResult qSource
Alias for ignorePat
.
Yielding only a result for expressions and ignoring in patterns.
ignoreExp :: EP q => AQResult Pat -> AQResult qSource
Yielding only a result for patterns and ignoring in expressions.
onlyPat :: EP q => AQResult Pat -> AQResult qSource
Alias for ignoreExp
.
Yielding only a result for patterns and ignoring in expressions.
Unsorted
splice :: EP q => String -> Q qSource
Uses/Binds a variable of the given name.
splice = varQ . mkName
wild :: EP q => Q Exp -> Q qSource
Use a wildcard in pattern context and the given expression in expression contexts. Consider for example the folowing constructor
EX SrcLoc OtherType
When pattern matching the pattern should look like EX _ x
, using a
wildcard for the source location. On the other hand making an expression
should use some result say resulting in EX someSrcLoc x
. With the wild
function this general quoter can be written as
con ''EX [wild someSrcLoc', splice "x"]
Assuming that someSrcLoc' :: ExpQ
and that its result is of type SrcLoc
.