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

Safe HaskellNone

Language.Haskell.AntiQuoter.Base

Contents

Description

Base module for AntiQuoters, which transform parsed syntax into template-haskell syntax to make QuasiQuoters.

Synopsis

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 AntiQuoterPasses, 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

Internals

newtype WrappedAQResult q Source

Wrapper for AQResult, needed for the typechecker.

Constructors

AQRW 

Fields

unAQRW :: AQResult q