bce8bf5ddb5bae7c178b1c9cc9a0067e090769eb
[ghc.git] / libraries / template-haskell / Language / Haskell / TH.hs
1 {- | The public face of Template Haskell
2
3 For other documentation, refer to:
4 <http://www.haskell.org/haskellwiki/Template_Haskell>
5
6 -}
7 module Language.Haskell.TH(
8 -- * The monad and its operations
9 Q,
10 runQ,
11 -- ** Administration: errors, locations and IO
12 reportError, -- :: String -> Q ()
13 reportWarning, -- :: String -> Q ()
14 report, -- :: Bool -> String -> Q ()
15 recover, -- :: Q a -> Q a -> Q a
16 location, -- :: Q Loc
17 Loc(..),
18 runIO, -- :: IO a -> Q a
19 -- ** Querying the compiler
20 -- *** Reify
21 reify, -- :: Name -> Q Info
22 reifyModule,
23 thisModule,
24 Info(..), ModuleInfo(..),
25 InstanceDec,
26 ParentName,
27 Arity,
28 Unlifted,
29 -- *** Name lookup
30 lookupTypeName, -- :: String -> Q (Maybe Name)
31 lookupValueName, -- :: String -> Q (Maybe Name)
32 -- *** Fixity lookup
33 reifyFixity,
34 -- *** Instance lookup
35 reifyInstances,
36 isInstance,
37 -- *** Roles lookup
38 reifyRoles,
39 -- *** Annotation lookup
40 reifyAnnotations, AnnLookup(..),
41
42 -- * Typed expressions
43 TExp, unType,
44
45 -- * Names
46 Name, NameSpace, -- Abstract
47 -- ** Constructing names
48 mkName, -- :: String -> Name
49 newName, -- :: String -> Q Name
50 -- ** Deconstructing names
51 nameBase, -- :: Name -> String
52 nameModule, -- :: Name -> Maybe String
53 namePackage, -- :: Name -> Maybe String
54 -- ** Built-in names
55 tupleTypeName, tupleDataName, -- Int -> Name
56 unboxedTupleTypeName, unboxedTupleDataName, -- :: Int -> Name
57
58 -- * The algebraic data types
59 -- | The lowercase versions (/syntax operators/) of these constructors are
60 -- preferred to these constructors, since they compose better with
61 -- quotations (@[| |]@) and splices (@$( ... )@)
62
63 -- ** Declarations
64 Dec(..), Con(..), Clause(..),
65 Strict(..), Foreign(..), Callconv(..), Safety(..), Pragma(..),
66 Inline(..), RuleMatch(..), Phases(..), RuleBndr(..), AnnTarget(..),
67 FunDep(..), FamFlavour(..), TySynEqn(..),
68 Fixity(..), FixityDirection(..), defaultFixity, maxPrecedence,
69 -- ** Expressions
70 Exp(..), Match(..), Body(..), Guard(..), Stmt(..), Range(..), Lit(..),
71 -- ** Patterns
72 Pat(..), FieldExp, FieldPat,
73 -- ** Types
74 Type(..), TyVarBndr(..), TyLit(..), Kind, Cxt, Pred, Syntax.Role(..),
75 FamilyResultSig(..), Syntax.InjectivityAnn(..),
76
77 -- * Library functions
78 -- ** Abbreviations
79 InfoQ, ExpQ, DecQ, DecsQ, ConQ, TypeQ, TyLitQ, CxtQ, PredQ, MatchQ, ClauseQ,
80 BodyQ, GuardQ, StmtQ, RangeQ, StrictTypeQ, VarStrictTypeQ, PatQ, FieldPatQ,
81 RuleBndrQ, TySynEqnQ,
82
83 -- ** Constructors lifted to 'Q'
84 -- *** Literals
85 intPrimL, wordPrimL, floatPrimL, doublePrimL, integerL, rationalL,
86 charL, stringL, stringPrimL, charPrimL,
87 -- *** Patterns
88 litP, varP, tupP, conP, uInfixP, parensP, infixP,
89 tildeP, bangP, asP, wildP, recP,
90 listP, sigP, viewP,
91 fieldPat,
92
93 -- *** Pattern Guards
94 normalB, guardedB, normalG, normalGE, patG, patGE, match, clause,
95
96 -- *** Expressions
97 dyn, varE, conE, litE, appE, uInfixE, parensE, staticE,
98 infixE, infixApp, sectionL, sectionR,
99 lamE, lam1E, lamCaseE, tupE, condE, multiIfE, letE, caseE, appsE,
100 listE, sigE, recConE, recUpdE, stringE, fieldExp,
101 -- **** Ranges
102 fromE, fromThenE, fromToE, fromThenToE,
103
104 -- ***** Ranges with more indirection
105 arithSeqE,
106 fromR, fromThenR, fromToR, fromThenToR,
107 -- **** Statements
108 doE, compE,
109 bindS, letS, noBindS, parS,
110
111 -- *** Types
112 forallT, varT, conT, appT, arrowT, infixT, uInfixT, parensT, equalityT,
113 listT, tupleT, sigT, litT, promotedT, promotedTupleT, promotedNilT,
114 promotedConsT,
115 -- **** Type literals
116 numTyLit, strTyLit,
117 -- **** Strictness
118 isStrict, notStrict, strictType, varStrictType,
119 -- **** Class Contexts
120 cxt, classP, equalP, normalC, recC, infixC, forallC,
121
122 -- *** Kinds
123 varK, conK, tupleK, arrowK, listK, appK, starK, constraintK,
124
125 -- *** Roles
126 nominalR, representationalR, phantomR, inferR,
127
128 -- *** Top Level Declarations
129 -- **** Data
130 valD, funD, tySynD, dataD, newtypeD,
131 -- **** Class
132 classD, instanceD, sigD, standaloneDerivD, defaultSigD,
133 -- **** Role annotations
134 roleAnnotD,
135 -- **** Type Family / Data Family
136 dataFamilyD, openTypeFamilyD, closedTypeFamilyD, dataInstD,
137 familyNoKindD, familyKindD, closedTypeFamilyNoKindD, closedTypeFamilyKindD,
138 newtypeInstD, tySynInstD,
139 typeFam, dataFam, tySynEqn, injectivityAnn, noSig, kindSig, tyVarSig,
140 -- **** Foreign Function Interface (FFI)
141 cCall, stdCall, cApi, prim, javaScript,
142 unsafe, safe, forImpD,
143 -- **** Pragmas
144 ruleVar, typedRuleVar,
145 pragInlD, pragSpecD, pragSpecInlD, pragSpecInstD, pragRuleD, pragAnnD,
146 pragLineD,
147
148 -- * Pretty-printer
149 Ppr(..), pprint, pprExp, pprLit, pprPat, pprParendType
150
151 ) where
152
153 import Language.Haskell.TH.Syntax as Syntax
154 import Language.Haskell.TH.Lib
155 import Language.Haskell.TH.Ppr