Language.Haskell.TH.Lib

template-haskell-2.8.0.0

Safe Haskell | None

Language.Haskell.TH.Lib

Contents

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

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 TyLitQ = Q TyLit
- 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 RuleBndrQ = Q RuleBndr
- intPrimL :: Integer -> Lit
- wordPrimL :: Integer -> Lit
- floatPrimL :: Rational -> Lit
- doublePrimL :: Rational -> Lit
- integerL :: Integer -> Lit
- charL :: Char -> Lit
- stringL :: String -> Lit
- stringPrimL :: [Word8] -> Lit
- rationalL :: Rational -> Lit
- litP :: Lit -> PatQ
- varP :: Name -> PatQ
- tupP :: [PatQ] -> PatQ
- unboxedTupP :: [PatQ] -> PatQ
- conP :: Name -> [PatQ] -> PatQ
- infixP :: PatQ -> Name -> PatQ -> PatQ
- uInfixP :: PatQ -> Name -> PatQ -> PatQ
- parensP :: 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
- parensE :: ExpQ -> ExpQ
- uInfixE :: ExpQ -> 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
- lamCaseE :: [MatchQ] -> ExpQ
- tupE :: [ExpQ] -> ExpQ
- unboxedTupE :: [ExpQ] -> ExpQ
- condE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
- multiIfE :: [Q (Guard, Exp)] -> 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
- infixLD :: Int -> Name -> DecQ
- infixRD :: Int -> Name -> DecQ
- infixND :: Int -> Name -> DecQ
- pragInlD :: Name -> Inline -> RuleMatch -> Phases -> DecQ
- pragSpecD :: Name -> TypeQ -> Phases -> DecQ
- pragSpecInlD :: Name -> TypeQ -> Inline -> Phases -> DecQ
- pragSpecInstD :: TypeQ -> DecQ
- pragRuleD :: String -> [RuleBndrQ] -> ExpQ -> ExpQ -> Phases -> 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
- litT :: TyLitQ -> TypeQ
- tupleT :: Int -> TypeQ
- unboxedTupleT :: Int -> TypeQ
- sigT :: TypeQ -> Kind -> TypeQ
- promotedT :: Name -> TypeQ
- promotedTupleT :: Int -> TypeQ
- promotedNilT :: TypeQ
- promotedConsT :: TypeQ
- isStrict :: Q Strict
- unpacked :: Q Strict
- notStrict :: Q Strict
- strictType :: Q Strict -> TypeQ -> StrictTypeQ
- varStrictType :: Name -> StrictTypeQ -> VarStrictTypeQ
- numTyLit :: Integer -> TyLitQ
- strTyLit :: String -> TyLitQ
- plainTV :: Name -> TyVarBndr
- kindedTV :: Name -> Kind -> TyVarBndr
- varK :: Name -> Kind
- conK :: Name -> Kind
- tupleK :: Int -> Kind
- arrowK :: Kind
- listK :: Kind
- appK :: Kind -> Kind -> Kind
- starK :: Kind
- constraintK :: Kind
- cCall :: Callconv
- stdCall :: Callconv
- unsafe :: Safety
- interruptible :: Safety
- safe :: Safety
- funDep :: [Name] -> [Name] -> FunDep
- typeFam :: FamFlavour
- dataFam :: FamFlavour
- ruleVar :: Name -> RuleBndrQ
- typedRuleVar :: Name -> TypeQ -> RuleBndrQ
- appsE :: [ExpQ] -> ExpQ

# Type synonyms

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 TyLitQ = Q TyLit

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 RuleBndrQ = Q RuleBndr

# Lowercase pattern syntax functions

intPrimL :: Integer -> Lit

wordPrimL :: Integer -> Lit

floatPrimL :: Rational -> Lit

doublePrimL :: Rational -> Lit

integerL :: Integer -> Lit

charL :: Char -> Lit

stringL :: String -> Lit

stringPrimL :: [Word8] -> Lit

rationalL :: Rational -> Lit

litP :: Lit -> PatQ

varP :: Name -> PatQ

tupP :: [PatQ] -> PatQ

unboxedTupP :: [PatQ] -> PatQ

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

infixP :: PatQ -> Name -> PatQ -> PatQ

uInfixP :: PatQ -> Name -> PatQ -> PatQ

parensP :: 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

# Stmt

bindS :: PatQ -> ExpQ -> StmtQ

letS :: [DecQ] -> StmtQ

noBindS :: ExpQ -> StmtQ

parS :: [[StmtQ]] -> StmtQ

# Range

fromR :: ExpQ -> RangeQ

fromThenR :: ExpQ -> ExpQ -> RangeQ

fromToR :: ExpQ -> ExpQ -> RangeQ

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

# Body

normalB :: ExpQ -> BodyQ

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

# Guard

normalG :: ExpQ -> GuardQ

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

patG :: [StmtQ] -> GuardQ

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

# Match and Clause

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

Use with `caseE`

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

Use with `funD`

# Exp

dyn :: String -> Q Exp

Dynamically binding a variable (unhygenic)

global :: Name -> ExpQ

varE :: Name -> ExpQ

conE :: Name -> ExpQ

litE :: Lit -> ExpQ

appE :: ExpQ -> ExpQ -> ExpQ

parensE :: ExpQ -> ExpQ

uInfixE :: ExpQ -> 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

Single-arg lambda

lamCaseE :: [MatchQ] -> ExpQ

tupE :: [ExpQ] -> ExpQ

unboxedTupE :: [ExpQ] -> ExpQ

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

multiIfE :: [Q (Guard, Exp)] -> 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)

## `arithSeqE` Shortcuts

fromE :: ExpQ -> ExpQ

fromThenE :: ExpQ -> ExpQ -> ExpQ

fromToE :: ExpQ -> ExpQ -> ExpQ

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

# Dec

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

infixLD :: Int -> Name -> DecQ

infixRD :: Int -> Name -> DecQ

infixND :: Int -> Name -> DecQ

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

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

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

pragSpecInstD :: TypeQ -> DecQ

pragRuleD :: String -> [RuleBndrQ] -> ExpQ -> ExpQ -> Phases -> 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

# Type

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

varT :: Name -> TypeQ

conT :: Name -> TypeQ

appT :: TypeQ -> TypeQ -> TypeQ

arrowT :: TypeQ

listT :: TypeQ

litT :: TyLitQ -> TypeQ

tupleT :: Int -> TypeQ

unboxedTupleT :: Int -> TypeQ

sigT :: TypeQ -> Kind -> TypeQ

promotedT :: Name -> TypeQ

promotedTupleT :: Int -> TypeQ

promotedNilT :: TypeQ

promotedConsT :: TypeQ

isStrict :: Q Strict

unpacked :: Q Strict

notStrict :: Q Strict

strictType :: Q Strict -> TypeQ -> StrictTypeQ

varStrictType :: Name -> StrictTypeQ -> VarStrictTypeQ

# Type Literals

numTyLit :: Integer -> TyLitQ

strTyLit :: String -> TyLitQ

# Kind

plainTV :: Name -> TyVarBndr

kindedTV :: Name -> Kind -> TyVarBndr

varK :: Name -> Kind

conK :: Name -> Kind

tupleK :: Int -> Kind

arrowK :: Kind

listK :: Kind

appK :: Kind -> Kind -> Kind

starK :: Kind

constraintK :: Kind

# Callconv

cCall :: Callconv

stdCall :: Callconv

# Safety

unsafe :: Safety

interruptible :: Safety

safe :: Safety

# FunDep

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

# FamFlavour

typeFam :: FamFlavour

dataFam :: FamFlavour

# RuleBndr

ruleVar :: Name -> RuleBndrQ

typedRuleVar :: Name -> TypeQ -> RuleBndrQ

# Useful helper function

appsE :: [ExpQ] -> ExpQ