Make dataToQa aware of Data instances which use functions to implement toConstr
[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 nameSpace, -- :: Name -> Maybe NameSpace
55 -- ** Built-in names
56 tupleTypeName, tupleDataName, -- Int -> Name
57 unboxedTupleTypeName, unboxedTupleDataName, -- :: Int -> Name
58
59 -- * The algebraic data types
60 -- | The lowercase versions (/syntax operators/) of these constructors are
61 -- preferred to these constructors, since they compose better with
62 -- quotations (@[| |]@) and splices (@$( ... )@)
63
64 -- ** Declarations
65 Dec(..), Con(..), Clause(..),
66 Strict(..), Foreign(..), Callconv(..), Safety(..), Pragma(..),
67 Inline(..), RuleMatch(..), Phases(..), RuleBndr(..), AnnTarget(..),
68 FunDep(..), FamFlavour(..), TySynEqn(..),
69 Fixity(..), FixityDirection(..), defaultFixity, maxPrecedence,
70 -- ** Expressions
71 Exp(..), Match(..), Body(..), Guard(..), Stmt(..), Range(..), Lit(..),
72 -- ** Patterns
73 Pat(..), FieldExp, FieldPat,
74 -- ** Types
75 Type(..), TyVarBndr(..), TyLit(..), Kind, Cxt, Pred, Syntax.Role(..),
76 FamilyResultSig(..), Syntax.InjectivityAnn(..),
77
78 -- * Library functions
79 -- ** Abbreviations
80 InfoQ, ExpQ, DecQ, DecsQ, ConQ, TypeQ, TyLitQ, CxtQ, PredQ, MatchQ, ClauseQ,
81 BodyQ, GuardQ, StmtQ, RangeQ, StrictTypeQ, VarStrictTypeQ, PatQ, FieldPatQ,
82 RuleBndrQ, TySynEqnQ,
83
84 -- ** Constructors lifted to 'Q'
85 -- *** Literals
86 intPrimL, wordPrimL, floatPrimL, doublePrimL, integerL, rationalL,
87 charL, stringL, stringPrimL, charPrimL,
88 -- *** Patterns
89 litP, varP, tupP, conP, uInfixP, parensP, infixP,
90 tildeP, bangP, asP, wildP, recP,
91 listP, sigP, viewP,
92 fieldPat,
93
94 -- *** Pattern Guards
95 normalB, guardedB, normalG, normalGE, patG, patGE, match, clause,
96
97 -- *** Expressions
98 dyn, varE, conE, litE, appE, uInfixE, parensE, staticE,
99 infixE, infixApp, sectionL, sectionR,
100 lamE, lam1E, lamCaseE, tupE, condE, multiIfE, letE, caseE, appsE,
101 listE, sigE, recConE, recUpdE, stringE, fieldExp,
102 -- **** Ranges
103 fromE, fromThenE, fromToE, fromThenToE,
104
105 -- ***** Ranges with more indirection
106 arithSeqE,
107 fromR, fromThenR, fromToR, fromThenToR,
108 -- **** Statements
109 doE, compE,
110 bindS, letS, noBindS, parS,
111
112 -- *** Types
113 forallT, varT, conT, appT, arrowT, infixT, uInfixT, parensT, equalityT,
114 listT, tupleT, sigT, litT, promotedT, promotedTupleT, promotedNilT,
115 promotedConsT,
116 -- **** Type literals
117 numTyLit, strTyLit,
118 -- **** Strictness
119 isStrict, notStrict, strictType, varStrictType,
120 -- **** Class Contexts
121 cxt, classP, equalP, normalC, recC, infixC, forallC,
122
123 -- *** Kinds
124 varK, conK, tupleK, arrowK, listK, appK, starK, constraintK,
125
126 -- *** Roles
127 nominalR, representationalR, phantomR, inferR,
128
129 -- *** Top Level Declarations
130 -- **** Data
131 valD, funD, tySynD, dataD, newtypeD,
132 -- **** Class
133 classD, instanceD, sigD, standaloneDerivD, defaultSigD,
134 -- **** Role annotations
135 roleAnnotD,
136 -- **** Type Family / Data Family
137 dataFamilyD, openTypeFamilyD, closedTypeFamilyD, dataInstD,
138 familyNoKindD, familyKindD, closedTypeFamilyNoKindD, closedTypeFamilyKindD,
139 newtypeInstD, tySynInstD,
140 typeFam, dataFam, tySynEqn, injectivityAnn, noSig, kindSig, tyVarSig,
141 -- **** Foreign Function Interface (FFI)
142 cCall, stdCall, cApi, prim, javaScript,
143 unsafe, safe, forImpD,
144 -- **** Pragmas
145 ruleVar, typedRuleVar,
146 pragInlD, pragSpecD, pragSpecInlD, pragSpecInstD, pragRuleD, pragAnnD,
147 pragLineD,
148
149 -- * Pretty-printer
150 Ppr(..), pprint, pprExp, pprLit, pprPat, pprParendType
151
152 ) where
153
154 import Language.Haskell.TH.Syntax as Syntax
155 import Language.Haskell.TH.Lib
156 import Language.Haskell.TH.Ppr