template-haskell-2.5.0.0

Language.Haskell.TH.Lib

Contents

- Type synonyms
- Lowercase pattern syntax functions
- Stmt
- Range
- Body
- Guard
- Match and Clause
- Exp
  - `arithSeqE` Shortcuts
- Dec
- Type
- Kind
- Callconv
- Safety
- InlineSpec
- FunDep
- FamFlavour
- Useful helper functions

Description

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

Synopsis

- type InfoQ = Q Info
- type PatQ = Q Pat
- type FieldPatQ = Q FieldPat
- type ExpQ = Q Exp
- type DecQ = Q Dec
- type DecsQ = Q [Dec]
- type ConQ = Q Con
- type TypeQ = Q Type
- type CxtQ = Q Cxt
- type PredQ = Q Pred
- type MatchQ = Q Match
- type ClauseQ = Q Clause
- type BodyQ = Q Body
- type GuardQ = Q Guard
- type StmtQ = Q Stmt
- type RangeQ = Q Range
- type StrictTypeQ = Q StrictType
- type VarStrictTypeQ = Q VarStrictType
- type FieldExpQ = Q FieldExp
- type InlineSpecQ = Q InlineSpec
- intPrimL :: Integer -> Lit
- wordPrimL :: Integer -> Lit
- floatPrimL :: Rational -> Lit
- doublePrimL :: Rational -> Lit
- integerL :: Integer -> Lit
- charL :: Char -> Lit
- stringL :: String -> Lit
- stringPrimL :: String -> Lit
- rationalL :: Rational -> Lit
- litP :: Lit -> PatQ
- varP :: Name -> PatQ
- tupP :: [PatQ] -> PatQ
- conP :: Name -> [PatQ] -> PatQ
- infixP :: PatQ -> Name -> PatQ -> PatQ
- tildeP :: PatQ -> PatQ
- bangP :: PatQ -> PatQ
- asP :: Name -> PatQ -> PatQ
- wildP :: PatQ
- recP :: Name -> [FieldPatQ] -> PatQ
- listP :: [PatQ] -> PatQ
- sigP :: PatQ -> TypeQ -> PatQ
- viewP :: ExpQ -> PatQ -> PatQ
- fieldPat :: Name -> PatQ -> FieldPatQ
- bindS :: PatQ -> ExpQ -> StmtQ
- letS :: [DecQ] -> StmtQ
- noBindS :: ExpQ -> StmtQ
- parS :: [[StmtQ]] -> StmtQ
- fromR :: ExpQ -> RangeQ
- fromThenR :: ExpQ -> ExpQ -> RangeQ
- fromToR :: ExpQ -> ExpQ -> RangeQ
- fromThenToR :: ExpQ -> ExpQ -> ExpQ -> RangeQ
- normalB :: ExpQ -> BodyQ
- guardedB :: [Q (Guard, Exp)] -> BodyQ
- normalG :: ExpQ -> GuardQ
- normalGE :: ExpQ -> ExpQ -> Q (Guard, Exp)
- patG :: [StmtQ] -> GuardQ
- patGE :: [StmtQ] -> ExpQ -> Q (Guard, Exp)
- match :: PatQ -> BodyQ -> [DecQ] -> MatchQ
- clause :: [PatQ] -> BodyQ -> [DecQ] -> ClauseQ
- dyn :: String -> Q Exp
- global :: Name -> ExpQ
- varE :: Name -> ExpQ
- conE :: Name -> ExpQ
- litE :: Lit -> ExpQ
- appE :: ExpQ -> ExpQ -> ExpQ
- infixE :: Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ
- infixApp :: ExpQ -> ExpQ -> ExpQ -> ExpQ
- sectionL :: ExpQ -> ExpQ -> ExpQ
- sectionR :: ExpQ -> ExpQ -> ExpQ
- lamE :: [PatQ] -> ExpQ -> ExpQ
- lam1E :: PatQ -> ExpQ -> ExpQ
- tupE :: [ExpQ] -> ExpQ
- condE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
- letE :: [DecQ] -> ExpQ -> ExpQ
- caseE :: ExpQ -> [MatchQ] -> ExpQ
- doE :: [StmtQ] -> ExpQ
- compE :: [StmtQ] -> ExpQ
- arithSeqE :: RangeQ -> ExpQ
- listE :: [ExpQ] -> ExpQ
- sigE :: ExpQ -> TypeQ -> ExpQ
- recConE :: Name -> [Q (Name, Exp)] -> ExpQ
- recUpdE :: ExpQ -> [Q (Name, Exp)] -> ExpQ
- stringE :: String -> ExpQ
- fieldExp :: Name -> ExpQ -> Q (Name, Exp)
- fromE :: ExpQ -> ExpQ
- fromThenE :: ExpQ -> ExpQ -> ExpQ
- fromToE :: ExpQ -> ExpQ -> ExpQ
- fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
- valD :: PatQ -> BodyQ -> [DecQ] -> DecQ
- funD :: Name -> [ClauseQ] -> DecQ
- tySynD :: Name -> [TyVarBndr] -> TypeQ -> DecQ
- dataD :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ
- newtypeD :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ
- classD :: CxtQ -> Name -> [TyVarBndr] -> [FunDep] -> [DecQ] -> DecQ
- instanceD :: CxtQ -> TypeQ -> [DecQ] -> DecQ
- sigD :: Name -> TypeQ -> DecQ
- forImpD :: Callconv -> Safety -> String -> Name -> TypeQ -> DecQ
- pragInlD :: Name -> InlineSpecQ -> DecQ
- pragSpecD :: Name -> TypeQ -> DecQ
- pragSpecInlD :: Name -> TypeQ -> InlineSpecQ -> DecQ
- familyNoKindD :: FamFlavour -> Name -> [TyVarBndr] -> DecQ
- familyKindD :: FamFlavour -> Name -> [TyVarBndr] -> Kind -> DecQ
- dataInstD :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ
- newtypeInstD :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ
- tySynInstD :: Name -> [TypeQ] -> TypeQ -> DecQ
- cxt :: [PredQ] -> CxtQ
- classP :: Name -> [TypeQ] -> PredQ
- equalP :: TypeQ -> TypeQ -> PredQ
- normalC :: Name -> [StrictTypeQ] -> ConQ
- recC :: Name -> [VarStrictTypeQ] -> ConQ
- infixC :: Q (Strict, Type) -> Name -> Q (Strict, Type) -> ConQ
- forallC :: [TyVarBndr] -> CxtQ -> ConQ -> ConQ
- forallT :: [TyVarBndr] -> CxtQ -> TypeQ -> TypeQ
- varT :: Name -> TypeQ
- conT :: Name -> TypeQ
- appT :: TypeQ -> TypeQ -> TypeQ
- arrowT :: TypeQ
- listT :: TypeQ
- tupleT :: Int -> TypeQ
- sigT :: TypeQ -> Kind -> TypeQ
- notStrict :: Q Strict
- isStrict :: Q Strict
- strictType :: Q Strict -> TypeQ -> StrictTypeQ
- varStrictType :: Name -> StrictTypeQ -> VarStrictTypeQ
- plainTV :: Name -> TyVarBndr
- kindedTV :: Name -> Kind -> TyVarBndr
- starK :: Kind
- arrowK :: Kind -> Kind -> Kind
- stdCall :: Callconv
- cCall :: Callconv
- safe :: Safety
- threadsafe :: Safety
- unsafe :: Safety
- inlineSpecNoPhase :: Bool -> Bool -> InlineSpecQ
- inlineSpecPhase :: Bool -> Bool -> Bool -> Int -> InlineSpecQ
- funDep :: [Name] -> [Name] -> FunDep
- dataFam :: FamFlavour
- typeFam :: FamFlavour
- combine :: [([(Name, Name)], Pat)] -> ([(Name, Name)], [Pat])
- rename :: Pat -> Q ([(Name, Name)], Pat)
- genpat :: Pat -> Q (Name -> ExpQ, Pat)
- alpha :: [(Name, Name)] -> Name -> ExpQ
- appsE :: [ExpQ] -> ExpQ
- simpleMatch :: Pat -> Exp -> Match

# Type synonyms

type InfoQ = Q Info Source

type PatQ = Q Pat Source

type FieldPatQ = Q FieldPat Source

type ExpQ = Q Exp Source

type DecQ = Q Dec Source

type DecsQ = Q [Dec]Source

type ConQ = Q Con Source

type TypeQ = Q Type Source

type CxtQ = Q Cxt Source

type PredQ = Q Pred 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 StrictTypeQ = Q StrictType Source

type VarStrictTypeQ = Q VarStrictType Source

type FieldExpQ = Q FieldExp Source

type InlineSpecQ = Q InlineSpec Source

# Lowercase pattern syntax functions

intPrimL :: Integer -> Lit Source

wordPrimL :: Integer -> Lit Source

floatPrimL :: Rational -> Lit Source

doublePrimL :: Rational -> Lit Source

integerL :: Integer -> Lit Source

charL :: Char -> Lit Source

stringL :: String -> Lit Source

stringPrimL :: String -> Lit Source

rationalL :: Rational -> Lit Source

litP :: Lit -> PatQ Source

varP :: Name -> PatQ Source

tupP :: [PatQ] -> PatQ Source

conP :: Name -> [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

# Stmt

bindS :: PatQ -> ExpQ -> StmtQ Source

letS :: [DecQ] -> StmtQ Source

noBindS :: ExpQ -> StmtQ Source

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

# Range

fromR :: ExpQ -> RangeQ Source

fromThenR :: ExpQ -> ExpQ -> RangeQ Source

fromToR :: ExpQ -> ExpQ -> RangeQ Source

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

# Body

normalB :: ExpQ -> BodyQ Source

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

# Guard

normalG :: ExpQ -> GuardQ Source

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

patG :: [StmtQ] -> GuardQ Source

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

# Match and Clause

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

Use with `caseE`

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

Use with `funD`

# Exp

dyn :: String -> Q Exp Source

Dynamically binding a variable (unhygenic)

global :: Name -> ExpQ Source

varE :: Name -> ExpQ Source

conE :: Name -> ExpQ Source

litE :: Lit -> ExpQ Source

appE :: ExpQ -> ExpQ -> ExpQ Source

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

tupE :: [ExpQ] -> ExpQ Source

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

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

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

doE :: [StmtQ] -> ExpQ Source

compE :: [StmtQ] -> ExpQ Source

arithSeqE :: RangeQ -> 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

## `arithSeqE` Shortcuts

fromE :: ExpQ -> ExpQ Source

fromThenE :: ExpQ -> ExpQ -> ExpQ Source

fromToE :: ExpQ -> ExpQ -> ExpQ Source

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

# Dec

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

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

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

dataD :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ Source

newtypeD :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ Source

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

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

sigD :: Name -> TypeQ -> DecQ Source

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

pragInlD :: Name -> InlineSpecQ -> DecQ Source

pragSpecD :: Name -> TypeQ -> DecQ Source

pragSpecInlD :: Name -> TypeQ -> InlineSpecQ -> DecQ Source

familyNoKindD :: FamFlavour -> Name -> [TyVarBndr] -> DecQ Source

familyKindD :: FamFlavour -> Name -> [TyVarBndr] -> Kind -> DecQ Source

dataInstD :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ Source

newtypeInstD :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ Source

tySynInstD :: Name -> [TypeQ] -> TypeQ -> DecQ Source

cxt :: [PredQ] -> CxtQ Source

classP :: Name -> [TypeQ] -> PredQ Source

equalP :: TypeQ -> TypeQ -> PredQ Source

normalC :: Name -> [StrictTypeQ] -> ConQ Source

recC :: Name -> [VarStrictTypeQ] -> ConQ Source

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

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

# Type

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

varT :: Name -> TypeQ Source

conT :: Name -> TypeQ Source

appT :: TypeQ -> TypeQ -> TypeQ Source

arrowT :: TypeQ Source

listT :: TypeQ Source

tupleT :: Int -> TypeQ Source

sigT :: TypeQ -> Kind -> TypeQ Source

notStrict :: Q Strict Source

isStrict :: Q Strict Source

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

varStrictType :: Name -> StrictTypeQ -> VarStrictTypeQ Source

# Kind

plainTV :: Name -> TyVarBndr Source

kindedTV :: Name -> Kind -> TyVarBndr Source

starK :: Kind Source

arrowK :: Kind -> Kind -> Kind Source

# Callconv

stdCall :: Callconv Source

cCall :: Callconv Source

# Safety

safe :: Safety Source

threadsafe :: Safety Source

unsafe :: Safety Source

# InlineSpec

inlineSpecNoPhase :: Bool -> Bool -> InlineSpecQ Source

inlineSpecPhase :: Bool -> Bool -> Bool -> Int -> InlineSpecQ Source

# FunDep

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

# FamFlavour

dataFam :: FamFlavour Source

typeFam :: FamFlavour Source

# Useful helper functions

combine :: [([(Name, Name)], Pat)] -> ([(Name, Name)], [Pat])Source

rename :: Pat -> Q ([(Name, Name)], Pat)Source

genpat :: Pat -> Q (Name -> ExpQ, Pat)Source

alpha :: [(Name, Name)] -> Name -> ExpQ Source

appsE :: [ExpQ] -> ExpQ Source

simpleMatch :: Pat -> Exp -> Match Source