template-haskell-2.13.0.0: Support library for Template Haskell

Safe HaskellSafe
LanguageHaskell2010

Language.Haskell.TH.Lib

Description

Language.Haskell.TH.Lib contains lots of useful helper functions for generating and manipulating Template Haskell terms

Synopsis

Library functions

Abbreviations

type InfoQ = Q Info Source #

type ExpQ = Q Exp Source #

type TExpQ a = Q (TExp a) Source #

type DecQ = Q Dec Source #

type DecsQ = Q [Dec] Source #

type ConQ = Q Con Source #

type TypeQ = Q Type Source #

type KindQ = Q Kind Source #

type TyVarBndrQ = Q TyVarBndr Source #

type TyLitQ = Q TyLit Source #

type CxtQ = Q Cxt Source #

type PredQ = Q Pred Source #

type DerivClauseQ = Q DerivClause Source #

type MatchQ = Q Match Source #

type ClauseQ = Q Clause Source #

type BodyQ = Q Body Source #

type GuardQ = Q Guard Source #

type StmtQ = Q Stmt Source #

type RangeQ = Q Range Source #

type SourceStrictnessQ = Q SourceStrictness Source #

type SourceUnpackednessQ = Q SourceUnpackedness Source #

type BangQ = Q Bang Source #

type BangTypeQ = Q BangType Source #

type VarBangTypeQ = Q VarBangType Source #

type StrictTypeQ = Q StrictType Source #

type VarStrictTypeQ = Q VarStrictType Source #

type FieldExpQ = Q FieldExp Source #

type PatQ = Q Pat Source #

type FieldPatQ = Q FieldPat Source #

type RuleBndrQ = Q RuleBndr Source #

type TySynEqnQ = Q TySynEqn Source #

type PatSynDirQ = Q PatSynDir Source #

type PatSynArgsQ = Q PatSynArgs Source #

type FamilyResultSigQ = Q FamilyResultSig Source #

Constructors lifted to Q

Literals

intPrimL :: Integer -> Lit Source #

wordPrimL :: Integer -> Lit Source #

floatPrimL :: Rational -> Lit Source #

doublePrimL :: Rational -> Lit Source #

integerL :: Integer -> Lit Source #

rationalL :: Rational -> Lit Source #

charL :: Char -> Lit Source #

stringL :: String -> Lit Source #

stringPrimL :: [Word8] -> Lit Source #

charPrimL :: Char -> Lit Source #

Patterns

litP :: Lit -> PatQ Source #

varP :: Name -> PatQ Source #

tupP :: [PatQ] -> PatQ Source #

unboxedTupP :: [PatQ] -> PatQ Source #

unboxedSumP :: PatQ -> SumAlt -> SumArity -> PatQ Source #

conP :: Name -> [PatQ] -> PatQ Source #

uInfixP :: PatQ -> Name -> PatQ -> PatQ Source #

parensP :: PatQ -> PatQ Source #

infixP :: PatQ -> Name -> PatQ -> PatQ Source #

tildeP :: PatQ -> PatQ Source #

bangP :: PatQ -> PatQ Source #

asP :: Name -> PatQ -> PatQ Source #

wildP :: PatQ Source #

recP :: Name -> [FieldPatQ] -> PatQ Source #

listP :: [PatQ] -> PatQ Source #

sigP :: PatQ -> TypeQ -> PatQ Source #

viewP :: ExpQ -> PatQ -> PatQ Source #

fieldPat :: Name -> PatQ -> FieldPatQ Source #

Pattern Guards

normalB :: ExpQ -> BodyQ Source #

guardedB :: [Q (Guard, Exp)] -> BodyQ Source #

normalG :: ExpQ -> GuardQ Source #

normalGE :: ExpQ -> ExpQ -> Q (Guard, Exp) Source #

patG :: [StmtQ] -> GuardQ Source #

patGE :: [StmtQ] -> ExpQ -> Q (Guard, Exp) Source #

match :: PatQ -> BodyQ -> [DecQ] -> MatchQ Source #

Use with caseE

clause :: [PatQ] -> BodyQ -> [DecQ] -> ClauseQ Source #

Use with funD

Expressions

dyn :: String -> ExpQ Source #

Dynamically binding a variable (unhygenic)

varE :: Name -> ExpQ Source #

unboundVarE :: Name -> ExpQ Source #

labelE :: String -> ExpQ Source #

conE :: Name -> ExpQ Source #

litE :: Lit -> ExpQ Source #

appE :: ExpQ -> ExpQ -> ExpQ Source #

appTypeE :: ExpQ -> TypeQ -> ExpQ Source #

uInfixE :: ExpQ -> ExpQ -> ExpQ -> ExpQ Source #

parensE :: ExpQ -> ExpQ Source #

staticE :: ExpQ -> ExpQ Source #

staticE x = [| static x |]

infixE :: Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ Source #

infixApp :: ExpQ -> ExpQ -> ExpQ -> ExpQ Source #

sectionL :: ExpQ -> ExpQ -> ExpQ Source #

sectionR :: ExpQ -> ExpQ -> ExpQ Source #

lamE :: [PatQ] -> ExpQ -> ExpQ Source #

lam1E :: PatQ -> ExpQ -> ExpQ Source #

Single-arg lambda

lamCaseE :: [MatchQ] -> ExpQ Source #

tupE :: [ExpQ] -> ExpQ Source #

unboxedTupE :: [ExpQ] -> ExpQ Source #

unboxedSumE :: ExpQ -> SumAlt -> SumArity -> ExpQ Source #

condE :: ExpQ -> ExpQ -> ExpQ -> ExpQ Source #

multiIfE :: [Q (Guard, Exp)] -> ExpQ Source #

letE :: [DecQ] -> ExpQ -> ExpQ Source #

caseE :: ExpQ -> [MatchQ] -> ExpQ Source #

appsE :: [ExpQ] -> ExpQ Source #

listE :: [ExpQ] -> ExpQ Source #

sigE :: ExpQ -> TypeQ -> ExpQ Source #

recConE :: Name -> [Q (Name, Exp)] -> ExpQ Source #

recUpdE :: ExpQ -> [Q (Name, Exp)] -> ExpQ Source #

stringE :: String -> ExpQ Source #

fieldExp :: Name -> ExpQ -> Q (Name, Exp) Source #

Ranges

fromE :: ExpQ -> ExpQ Source #

fromThenE :: ExpQ -> ExpQ -> ExpQ Source #

fromToE :: ExpQ -> ExpQ -> ExpQ Source #

fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ Source #

Ranges with more indirection

arithSeqE :: RangeQ -> ExpQ Source #

fromR :: ExpQ -> RangeQ Source #

fromThenR :: ExpQ -> ExpQ -> RangeQ Source #

fromToR :: ExpQ -> ExpQ -> RangeQ Source #

fromThenToR :: ExpQ -> ExpQ -> ExpQ -> RangeQ Source #

Statements

doE :: [StmtQ] -> ExpQ Source #

compE :: [StmtQ] -> ExpQ Source #

bindS :: PatQ -> ExpQ -> StmtQ Source #

letS :: [DecQ] -> StmtQ Source #

noBindS :: ExpQ -> StmtQ Source #

parS :: [[StmtQ]] -> StmtQ Source #

Types

forallT :: [TyVarBndr] -> CxtQ -> TypeQ -> TypeQ Source #

varT :: Name -> TypeQ Source #

conT :: Name -> TypeQ Source #

appT :: TypeQ -> TypeQ -> TypeQ Source #

arrowT :: TypeQ Source #

infixT :: TypeQ -> Name -> TypeQ -> TypeQ Source #

uInfixT :: TypeQ -> Name -> TypeQ -> TypeQ Source #

parensT :: TypeQ -> TypeQ Source #

equalityT :: TypeQ Source #

listT :: TypeQ Source #

tupleT :: Int -> TypeQ Source #

unboxedTupleT :: Int -> TypeQ Source #

unboxedSumT :: SumArity -> TypeQ Source #

sigT :: TypeQ -> Kind -> TypeQ Source #

litT :: TyLitQ -> TypeQ Source #

wildCardT :: TypeQ Source #

promotedT :: Name -> TypeQ Source #

promotedTupleT :: Int -> TypeQ Source #

promotedNilT :: TypeQ Source #

promotedConsT :: TypeQ Source #

Type literals

numTyLit :: Integer -> TyLitQ Source #

strTyLit :: String -> TyLitQ Source #

Strictness

noSourceUnpackedness :: SourceUnpackednessQ Source #

sourceNoUnpack :: SourceUnpackednessQ Source #

sourceUnpack :: SourceUnpackednessQ Source #

noSourceStrictness :: SourceStrictnessQ Source #

sourceLazy :: SourceStrictnessQ Source #

sourceStrict :: SourceStrictnessQ Source #

isStrict :: Q Strict Source #

Deprecated: Use bang . See https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0. Example usage: 'bang noSourceUnpackedness sourceStrict'

notStrict :: Q Strict Source #

Deprecated: Use bang . See https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0. Example usage: 'bang noSourceUnpackedness noSourceStrictness'

unpacked :: Q Strict Source #

Deprecated: Use bang . See https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0. Example usage: 'bang sourceUnpack sourceStrict'

bang :: SourceUnpackednessQ -> SourceStrictnessQ -> BangQ Source #

bangType :: BangQ -> TypeQ -> BangTypeQ Source #

varBangType :: Name -> BangTypeQ -> VarBangTypeQ Source #

strictType :: Q Strict -> TypeQ -> StrictTypeQ Source #

Deprecated: As of template-haskell-2.11.0.0, StrictType has been replaced by BangType . Please use bangType instead.

varStrictType :: Name -> StrictTypeQ -> VarStrictTypeQ Source #

Deprecated: As of template-haskell-2.11.0.0, VarStrictType has been replaced by VarBangType . Please use varBangType instead.

Class Contexts

cxt :: [PredQ] -> CxtQ Source #

classP :: Name -> [Q Type] -> Q Pred Source #

Deprecated: As of template-haskell-2.10, constraint predicates (Pred) are just types (Type), in keeping with ConstraintKinds. Please use conT and appT .

equalP :: TypeQ -> TypeQ -> PredQ Source #

Deprecated: As of template-haskell-2.10, constraint predicates (Pred) are just types (Type), in keeping with ConstraintKinds. Please see equalityT .

Constructors

normalC :: Name -> [BangTypeQ] -> ConQ Source #

recC :: Name -> [VarBangTypeQ] -> ConQ Source #

infixC :: Q (Bang, Type) -> Name -> Q (Bang, Type) -> ConQ Source #

forallC :: [TyVarBndr] -> CxtQ -> ConQ -> ConQ Source #

gadtC :: [Name] -> [StrictTypeQ] -> TypeQ -> ConQ Source #

recGadtC :: [Name] -> [VarStrictTypeQ] -> TypeQ -> ConQ Source #

Kinds

varK :: Name -> Kind Source #

conK :: Name -> Kind Source #

tupleK :: Int -> Kind Source #

arrowK :: Kind Source #

listK :: Kind Source #

appK :: Kind -> Kind -> Kind Source #

starK :: Kind Source #

constraintK :: Kind Source #

Type variable binders

plainTV :: Name -> TyVarBndr Source #

kindedTV :: Name -> Kind -> TyVarBndr Source #

Roles

nominalR :: Role Source #

representationalR :: Role Source #

phantomR :: Role Source #

inferR :: Role Source #

Top Level Declarations

Data

valD :: PatQ -> BodyQ -> [DecQ] -> DecQ Source #

funD :: Name -> [ClauseQ] -> DecQ Source #

tySynD :: Name -> [TyVarBndr] -> TypeQ -> DecQ Source #

dataD :: CxtQ -> Name -> [TyVarBndr] -> Maybe Kind -> [ConQ] -> [DerivClauseQ] -> DecQ Source #

newtypeD :: CxtQ -> Name -> [TyVarBndr] -> Maybe Kind -> ConQ -> [DerivClauseQ] -> DecQ Source #

derivClause :: Maybe DerivStrategy -> [PredQ] -> DerivClauseQ Source #

data DerivClause Source #

A single deriving clause at the end of a datatype.

Constructors

DerivClause (Maybe DerivStrategy) Cxt
{ deriving stock (Eq, Ord) }
Instances
Instance details
Instance details

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DerivClause -> c DerivClause #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DerivClause #

toConstr :: DerivClause -> Constr #

dataTypeOf :: DerivClause -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DerivClause) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DerivClause) #

gmapT :: (forall b. Data b => b -> b) -> DerivClause -> DerivClause #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DerivClause -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DerivClause -> r #

gmapQ :: (forall d. Data d => d -> u) -> DerivClause -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DerivClause -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DerivClause -> m DerivClause #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DerivClause -> m DerivClause #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DerivClause -> m DerivClause #

Instance details
Instance details

Associated Types

type Rep DerivClause :: * -> * #

Instance details

data DerivStrategy Source #

What the user explicitly requests when deriving an instance.

Constructors

StockStrategy

A "standard" derived instance

AnyclassStrategy
-XDeriveAnyClass
NewtypeStrategy
-XGeneralizedNewtypeDeriving
Instances
Instance details
Instance details

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DerivStrategy -> c DerivStrategy #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DerivStrategy #

toConstr :: DerivStrategy -> Constr #

dataTypeOf :: DerivStrategy -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DerivStrategy) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DerivStrategy) #

gmapT :: (forall b. Data b => b -> b) -> DerivStrategy -> DerivStrategy #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DerivStrategy -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DerivStrategy -> r #

gmapQ :: (forall d. Data d => d -> u) -> DerivStrategy -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DerivStrategy -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DerivStrategy -> m DerivStrategy #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DerivStrategy -> m DerivStrategy #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DerivStrategy -> m DerivStrategy #

Instance details
Instance details

Associated Types

type Rep DerivStrategy :: * -> * #

Instance details
type Rep DerivStrategy = D1 (MetaData "DerivStrategy" "Language.Haskell.TH.Syntax" "template-haskell" False) (C1 (MetaCons "StockStrategy" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "AnyclassStrategy" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "NewtypeStrategy" PrefixI False) (U1 :: * -> *)))

Class

classD :: CxtQ -> Name -> [TyVarBndr] -> [FunDep] -> [DecQ] -> DecQ Source #

instanceD :: CxtQ -> TypeQ -> [DecQ] -> DecQ Source #

instanceWithOverlapD :: Maybe Overlap -> CxtQ -> TypeQ -> [DecQ] -> DecQ Source #

data Overlap Source #

Varieties of allowed instance overlap.

Constructors

Overlappable

May be overlapped by more specific instances

Overlapping

May overlap a more general instance

Incoherent

Both Overlappable and Overlappable , and pick an arbitrary one if multiple choices are available.

Instances
Instance details

Methods

(==) :: Overlap -> Overlap -> Bool #

(/=) :: Overlap -> Overlap -> Bool #

Instance details

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Overlap -> c Overlap #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Overlap #

toConstr :: Overlap -> Constr #

dataTypeOf :: Overlap -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Overlap) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Overlap) #

gmapT :: (forall b. Data b => b -> b) -> Overlap -> Overlap #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Overlap -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Overlap -> r #

gmapQ :: (forall d. Data d => d -> u) -> Overlap -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Overlap -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Overlap -> m Overlap #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Overlap -> m Overlap #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Overlap -> m Overlap #

Instance details
Instance details

Methods

showsPrec :: Int -> Overlap -> ShowS #

show :: Overlap -> String #

showList :: [Overlap] -> ShowS #

Instance details

Associated Types

type Rep Overlap :: * -> * #

Methods

from :: Overlap -> Rep Overlap x #

to :: Rep Overlap x -> Overlap #

Instance details
type Rep Overlap = D1 (MetaData "Overlap" "Language.Haskell.TH.Syntax" "template-haskell" False) ((C1 (MetaCons "Overlappable" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "Overlapping" PrefixI False) (U1 :: * -> *)) :+: (C1 (MetaCons "Overlaps" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "Incoherent" PrefixI False) (U1 :: * -> *)))

sigD :: Name -> TypeQ -> DecQ Source #

standaloneDerivD :: CxtQ -> TypeQ -> DecQ Source #

standaloneDerivWithStrategyD :: Maybe DerivStrategy -> CxtQ -> TypeQ -> DecQ Source #

defaultSigD :: Name -> TypeQ -> DecQ Source #

Role annotations

roleAnnotD :: Name -> [Role] -> DecQ Source #

Type Family / Data Family

dataFamilyD :: Name -> [TyVarBndr] -> Maybe Kind -> DecQ Source #

openTypeFamilyD :: Name -> [TyVarBndr] -> FamilyResultSig -> Maybe InjectivityAnn -> DecQ Source #

closedTypeFamilyD :: Name -> [TyVarBndr] -> FamilyResultSig -> Maybe InjectivityAnn -> [TySynEqnQ] -> DecQ Source #

dataInstD :: CxtQ -> Name -> [TypeQ] -> Maybe Kind -> [ConQ] -> [DerivClauseQ] -> DecQ Source #

newtypeInstD :: CxtQ -> Name -> [TypeQ] -> Maybe Kind -> ConQ -> [DerivClauseQ] -> DecQ Source #

tySynInstD :: Name -> TySynEqnQ -> DecQ Source #

tySynEqn :: [TypeQ] -> TypeQ -> TySynEqnQ Source #

injectivityAnn :: Name -> [Name] -> InjectivityAnn Source #

noSig :: FamilyResultSig Source #

kindSig :: Kind -> FamilyResultSig Source #

tyVarSig :: TyVarBndr -> FamilyResultSig Source #

Fixity

infixLD :: Int -> Name -> DecQ Source #

infixRD :: Int -> Name -> DecQ Source #

infixND :: Int -> Name -> DecQ Source #

Foreign Function Interface (FFI)

cCall :: Callconv Source #

stdCall :: Callconv Source #

cApi :: Callconv Source #

prim :: Callconv Source #

javaScript :: Callconv Source #

unsafe :: Safety Source #

safe :: Safety Source #

interruptible :: Safety Source #

forImpD :: Callconv -> Safety -> String -> Name -> TypeQ -> DecQ Source #

Functional dependencies

funDep :: [Name] -> [Name] -> FunDep Source #

Pragmas

ruleVar :: Name -> RuleBndrQ Source #

typedRuleVar :: Name -> TypeQ -> RuleBndrQ Source #

valueAnnotation :: Name -> AnnTarget Source #

typeAnnotation :: Name -> AnnTarget Source #

moduleAnnotation :: AnnTarget Source #

pragInlD :: Name -> Inline -> RuleMatch -> Phases -> DecQ Source #

pragSpecD :: Name -> TypeQ -> Phases -> DecQ Source #

pragSpecInlD :: Name -> TypeQ -> Inline -> Phases -> DecQ Source #

pragSpecInstD :: TypeQ -> DecQ Source #

pragRuleD :: String -> [RuleBndrQ] -> ExpQ -> ExpQ -> Phases -> DecQ Source #

pragAnnD :: AnnTarget -> ExpQ -> DecQ Source #

pragLineD :: Int -> String -> DecQ Source #

pragCompleteD :: [Name] -> Maybe Name -> DecQ Source #

Pattern Synonyms

patSynD :: Name -> PatSynArgsQ -> PatSynDirQ -> PatQ -> DecQ Source #

Pattern synonym declaration

patSynSigD :: Name -> TypeQ -> DecQ Source #

Pattern synonym type signature

unidir :: PatSynDirQ Source #

implBidir :: PatSynDirQ Source #

explBidir :: [ClauseQ] -> PatSynDirQ Source #

prefixPatSyn :: [Name] -> PatSynArgsQ Source #

infixPatSyn :: Name -> Name -> PatSynArgsQ Source #

recordPatSyn :: [Name] -> PatSynArgsQ Source #

Reify

thisModule :: Q Module Source #

Return the Module at the place of splicing. Can be used as an input for reifyModule .

AltStyle によって変換されたページ (->オリジナル) /