summaryrefslogtreecommitdiff
path: root/libraries/template-haskell/Language/Haskell/TH.hs
blob: 58521453369acbec9f85c96609bd0e1848160ce0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{- | The public face of Template Haskell

For other documentation, refer to:
<http://www.haskell.org/haskellwiki/Template_Haskell>

-}
module Language.Haskell.TH(
	-- * The monad and its operations
	Q,
	runQ,
        -- ** Administration: errors, locations and IO
	reportError,		  -- :: String -> Q ()
	reportWarning,		  -- :: String -> Q ()
	report,			  -- :: Bool -> String -> Q ()
	recover, 	  -- :: Q a -> Q a -> Q a
	location,	  -- :: Q Loc
	Loc(..),
	runIO, 		  -- :: IO a -> Q a
	-- ** Querying the compiler
	-- *** Reify
	reify, 		  -- :: Name -> Q Info
	reifyModule,
	thisModule,
	Info(..), ModuleInfo(..),
	InstanceDec,
	ParentName,
	Arity,
	Unlifted,
	-- *** Name lookup
	lookupTypeName,	 -- :: String -> Q (Maybe Name)
	lookupValueName, -- :: String -> Q (Maybe Name)
	-- *** Instance lookup
	reifyInstances,
	isInstance,
        -- *** Roles lookup
        reifyRoles,
        -- *** Annotation lookup
        reifyAnnotations, AnnLookup(..),

	-- * Typed expressions
	TExp, unType,

	-- * Names
	Name, NameSpace,	-- Abstract
	-- ** Constructing names
	mkName,  	-- :: String -> Name
	newName, 	-- :: String -> Q Name
	-- ** Deconstructing names
	nameBase,	-- :: Name -> String
	nameModule,	-- :: Name -> Maybe String
	-- ** Built-in names
	tupleTypeName, tupleDataName,	-- Int -> Name
	unboxedTupleTypeName, unboxedTupleDataName, -- :: Int -> Name

    -- * The algebraic data types
    -- | The lowercase versions (/syntax operators/) of these constructors are
    -- preferred to these constructors, since they compose better with
    -- quotations (@[| |]@) and splices (@$( ... )@)

    -- ** Declarations
	Dec(..), Con(..), Clause(..),
	Strict(..), Foreign(..), Callconv(..), Safety(..), Pragma(..),
	Inline(..), RuleMatch(..), Phases(..), RuleBndr(..), AnnTarget(..),
	FunDep(..), FamFlavour(..), TySynEqn(..),
	Fixity(..), FixityDirection(..), defaultFixity, maxPrecedence,
    -- ** Expressions
        Exp(..), Match(..), Body(..), Guard(..), Stmt(..), Range(..), Lit(..),
    -- ** Patterns
        Pat(..), FieldExp, FieldPat,
    -- ** Types
        Type(..), TyVarBndr(..), TyLit(..), Kind, Cxt, Pred, Syntax.Role(..),

    -- * Library functions
    -- ** Abbreviations
        InfoQ, ExpQ, DecQ, DecsQ, ConQ, TypeQ, TyLitQ, CxtQ, PredQ, MatchQ, ClauseQ,
        BodyQ, GuardQ, StmtQ, RangeQ, StrictTypeQ, VarStrictTypeQ, PatQ, FieldPatQ,
        RuleBndrQ, TySynEqnQ,

    -- ** Constructors lifted to 'Q'
    -- *** Literals
	intPrimL, wordPrimL, floatPrimL, doublePrimL, integerL, rationalL,
	charL, stringL, stringPrimL,
    -- *** Patterns
	litP, varP, tupP, conP, uInfixP, parensP, infixP,
	tildeP, bangP, asP, wildP, recP,
	listP, sigP, viewP,
	fieldPat,

    -- *** Pattern Guards
	normalB, guardedB, normalG, normalGE, patG, patGE, match, clause,

    -- *** Expressions
	dyn, global, varE, conE, litE, appE, uInfixE, parensE,
	infixE, infixApp, sectionL, sectionR,
	lamE, lam1E, lamCaseE, tupE, condE, multiIfE, letE, caseE, appsE,
	listE, sigE, recConE, recUpdE, stringE, fieldExp,
    -- **** Ranges
    fromE, fromThenE, fromToE, fromThenToE,

    -- ***** Ranges with more indirection
    arithSeqE,
    fromR, fromThenR, fromToR, fromThenToR,
    -- **** Statements
    doE, compE,
    bindS, letS, noBindS, parS,

    -- *** Types
	forallT, varT, conT, appT, arrowT, equalityT, listT, tupleT, sigT, litT,
    promotedT, promotedTupleT, promotedNilT, promotedConsT,
    -- **** Type literals
    numTyLit, strTyLit,
    -- **** Strictness
	isStrict, notStrict, strictType, varStrictType,
    -- **** Class Contexts
    cxt, classP, equalP, normalC, recC, infixC, forallC,

    -- *** Kinds
  varK, conK, tupleK, arrowK, listK, appK, starK, constraintK,

    -- *** Roles
    nominalR, representationalR, phantomR, inferR,

    -- *** Top Level Declarations
    -- **** Data
	valD, funD, tySynD, dataD, newtypeD,
    -- **** Class
    classD, instanceD, sigD,
    -- **** Role annotations
    roleAnnotD,
    -- **** Type Family / Data Family
    familyNoKindD, familyKindD, dataInstD,
    closedTypeFamilyNoKindD, closedTypeFamilyKindD,
    newtypeInstD, tySynInstD,
    typeFam, dataFam, tySynEqn,
    -- **** Foreign Function Interface (FFI)
    cCall, stdCall, unsafe, safe, forImpD,
    -- **** Pragmas
    ruleVar, typedRuleVar,
    pragInlD, pragSpecD, pragSpecInlD, pragSpecInstD, pragRuleD, pragAnnD,

	-- * Pretty-printer
    Ppr(..), pprint, pprExp, pprLit, pprPat, pprParendType

   ) where

import Language.Haskell.TH.Syntax as Syntax
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Ppr