Safe Haskell | None |
---|
Base module for AntiQuoter
s, which transform parsed syntax into
template-haskell syntax to make QuasiQuoter
s.
- type AntiQuoterPass e q = e -> Maybe (Q q)
- type AntiQuoter q = forall e. Typeable e => AntiQuoterPass e q
- mkQuasiQuoter :: Data a => (String -> Q a) -> AntiQuoter Exp -> AntiQuoter Pat -> QuasiQuoter
- type AQResult q = Maybe (Q q)
- fromPass :: Typeable e => AntiQuoterPass e q -> AntiQuoter q
- (<<>) :: Typeable e => AntiQuoter q -> AntiQuoterPass e q -> AntiQuoter q
- (<>>) :: Typeable e => AntiQuoterPass e q -> AntiQuoter q -> AntiQuoter q
- extQ :: (Typeable a, Typeable b) => (a -> q) -> (b -> q) -> a -> q
- newtype WrappedAQResult q = AQRW {}
AntiQuoters
type AntiQuoterPass e q = e -> Maybe (Q q)Source
A single quotation pass possibly transforming an e
into a q
.
type AntiQuoter q = forall e. Typeable e => AntiQuoterPass e qSource
An AntiQuoter
is the combination of several AntiQuoterPass
es, trying
each of them in order until one passes.
mkQuasiQuoter :: Data a => (String -> Q a) -> AntiQuoter Exp -> AntiQuoter Pat -> QuasiQuoterSource
Create an QuasiQuoter for expressions and patterns from a parser and two antiquoters.
type AQResult q = Maybe (Q q)Source
Result of an AntiQuoterPass
fromPass :: Typeable e => AntiQuoterPass e q -> AntiQuoter qSource
Create an AntiQuoter
from an single pass.
(<<>) :: Typeable e => AntiQuoter q -> AntiQuoterPass e q -> AntiQuoter qSource
Combine an existing AntiQuoter
with an extra pass, where the extra pass
is tried if the current quoter fails.
(<>>) :: Typeable e => AntiQuoterPass e q -> AntiQuoter q -> AntiQuoter qSource
Like <>>
with flipped arguments, but also trying the extra pass before
the quoter.
Convenience reexport
WARNING: when combining AntiQuoter(Pass)es using extQ
only the
WARNING: when combining AntiQuoter(Pass)es using extQ
only the
last (rightmost) pass will be used for any source type. The <<>
and <>>
don't suffer from this problem.
extQ :: (Typeable a, Typeable b) => (a -> q) -> (b -> q) -> a -> q
Extend a generic query by a type-specific case