antiquoter-0.1.0.0: Combinator library for quasi- and anti-quoting.

Safe HaskellNone

Language.Haskell.AntiQuoter.Combinators

Contents

Description

Several combinators for AntiQuoters.

Synopsis

Lifted constructors.

varQ :: EP q => Name -> Q qSource

conQ :: EP q => Name -> [Q q] -> Q qSource

litQ :: EP q => Lit -> Q qSource

tupQ :: EP q => [Q q] -> Q qSource

listQ :: EP q => [Q q] -> Q qSource

Ignoring

ignore :: AQResult qSource

An results that does not output anything.

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.

nonsenseP :: EP q => String -> AQResult Exp -> AQResult qSource

A failing result for patterns, useful for when a the pattern matched by the using functions should never happen when antiquoting patterns.

nonsenseE :: EP q => String -> AQResult Pat -> AQResult qSource

See nonsenseP but failing on expresions.