Ticket #1576: format-most-comments-for-haddock_.dpatch

File format-most-comments-for-haddock_.dpatch, 35.4 KB (added by aavogt, 3 years ago)

TH API haddocks

Line 
12 patches for repository http://darcs.haskell.org/libraries/template-haskell:
2
3Tue Apr 27 00:05:31 EDT 2010  Adam Vogt <vogt.adam@gmail.com>
4  * Format most comments for haddock.
5
6Tue Apr 27 00:06:47 EDT 2010  Adam Vogt <vogt.adam@gmail.com>
7  * Document Info with named fields.
8
9New patches:
10
11[Format most comments for haddock.
12Adam Vogt <vogt.adam@gmail.com>**20100427040531
13 Ignore-this: 14d84e01ea50728748fad72faa28271e
14] {
15hunk ./Language/Haskell/TH.hs 1
16--- The public face of Template Haskell
17+{- | The public face of Template Haskell
18 
19hunk ./Language/Haskell/TH.hs 3
20+For other documentation, refer to:
21+<http://www.haskell.org/haskellwiki/Template_Haskell>
22+
23+-}
24 module Language.Haskell.TH(
25hunk ./Language/Haskell/TH.hs 8
26-       -- The monad and its operations
27+       -- * The monad and its operations
28        Q, runQ,
29        report,           -- :: Bool -> String -> Q ()
30        recover,          -- :: Q a -> Q a -> Q a
31hunk ./Language/Haskell/TH.hs 16
32        location,         -- :: Q Location
33        runIO,            -- :: IO a -> Q a
34 
35-       -- Names
36+       -- * Names
37        Name,
38        mkName,         -- :: String -> Name
39        newName,        -- :: String -> Q Name
40hunk ./Language/Haskell/TH.hs 24
41        nameModule,     -- :: Name -> Maybe String
42        tupleTypeName, tupleDataName,   -- Int -> Name
43       
44-       -- The algebraic data types
45+    -- * The algebraic data types
46+    -- | The lowercase versions (/syntax operators/) of these constructors are
47+    -- preferred to these constructors, since they compose better with
48+    -- quotations (@[| |]@) and splices (@$( ... )@)
49        Dec(..), Exp(..), Con(..), Type(..), TyVarBndr(..), Kind(..), Cxt,
50        Pred(..), Match(..), Clause(..), Body(..), Guard(..), Stmt(..),
51        Range(..), Lit(..), Pat(..), FieldExp, FieldPat,
52hunk ./Language/Haskell/TH.hs 35
53        InlineSpec(..), FunDep(..), FamFlavour(..), Info(..), Loc(..),
54        Fixity(..), FixityDirection(..), defaultFixity, maxPrecedence,
55 
56-       -- Library functions
57+    -- * Library functions
58+    -- ** Abbreviations
59        InfoQ, ExpQ, DecQ, ConQ, TypeQ, CxtQ, PredQ, MatchQ, ClauseQ, BodyQ,
60        GuardQ, StmtQ, RangeQ, StrictTypeQ, VarStrictTypeQ, PatQ, FieldPatQ,
61         InlineSpecQ,
62hunk ./Language/Haskell/TH.hs 40
63+
64+    -- ** Constructors lifted to 'Q'
65+    -- *** Litterals
66        intPrimL, wordPrimL, floatPrimL, doublePrimL, integerL, rationalL,
67        charL, stringL,
68hunk ./Language/Haskell/TH.hs 45
69+    -- *** Patterns
70        litP, varP, tupP, conP, infixP, tildeP, bangP, asP, wildP, recP,
71        listP, sigP,
72        fieldPat,
73hunk ./Language/Haskell/TH.hs 49
74-       bindS, letS, noBindS, parS,
75-       fromR, fromThenR, fromToR, fromThenToR,
76+
77+    -- *** Pattern Guards
78        normalB, guardedB, normalG, normalGE, patG, patGE, match, clause,
79hunk ./Language/Haskell/TH.hs 52
80+
81+    -- *** Expressions
82        dyn, global, varE, conE, litE, appE, infixE, infixApp, sectionL, sectionR,
83hunk ./Language/Haskell/TH.hs 55
84-       lamE, lam1E, tupE, condE, letE, caseE, doE, compE, arithSeqE, appsE,
85-       fromE, fromThenE, fromToE, fromThenToE,
86+       lamE, lam1E, tupE, condE, letE, caseE, appsE,
87        listE, sigE, recConE, recUpdE, stringE, fieldExp,
88hunk ./Language/Haskell/TH.hs 57
89-       valD, funD, tySynD, dataD, newtypeD, classD, instanceD, sigD, forImpD,
90-        pragInlD, pragSpecD, familyNoKindD, familyKindD, dataInstD,
91-        newtypeInstD, tySynInstD,
92-       cxt, classP, equalP, normalC, recC, infixC,
93+    -- **** Ranges
94+    fromE, fromThenE, fromToE, fromThenToE,
95+
96+    -- ***** Ranges with more indirection
97+    arithSeqE,
98+    fromR, fromThenR, fromToR, fromThenToR,
99+    -- **** Statements
100+    doE, compE,
101+    bindS, letS, noBindS, parS,
102+
103+    -- *** Types
104        forallT, varT, conT, appT, arrowT, listT, tupleT, sigT,
105hunk ./Language/Haskell/TH.hs 69
106+    -- **** Strictness
107        isStrict, notStrict, strictType, varStrictType,
108hunk ./Language/Haskell/TH.hs 71
109-       cCall, stdCall, unsafe, safe, threadsafe,
110-        inlineSpecNoPhase, inlineSpecPhase, typeFam, dataFam,
111+    -- **** Class Contexts
112+    cxt, classP, equalP, normalC, recC, infixC,
113+
114+    -- *** Top Level Declarations
115+    -- **** Data
116+       valD, funD, tySynD, dataD, newtypeD,
117+    -- **** Class
118+    classD, instanceD, sigD,
119+    -- **** Type Family / Data Family
120+    familyNoKindD, familyKindD, dataInstD,
121+    newtypeInstD, tySynInstD,
122+    typeFam, dataFam,
123+    -- **** Foreign Function Interface (FFI)
124+    cCall, stdCall, unsafe, safe, threadsafe, forImpD,
125+    -- **** Pragmas
126+    -- | Just inline supported so far
127+    inlineSpecNoPhase, inlineSpecPhase,
128+    pragInlD, pragSpecD,
129 
130hunk ./Language/Haskell/TH.hs 90
131-       -- Pretty-printer
132+       -- * Pretty-printer
133        Ppr(..), pprint, pprExp, pprLit, pprPat, pprParendType
134       
135    ) where
136hunk ./Language/Haskell/TH/Lib.hs 1
137+-- |
138 -- TH.Lib contains lots of useful helper functions for
139 -- generating and manipulating Template Haskell terms
140 
141hunk ./Language/Haskell/TH/Lib.hs 14
142 import Control.Monad( liftM, liftM2 )
143 
144 ----------------------------------------------------------
145--- Type synonyms
146+-- * Type synonyms
147 ----------------------------------------------------------
148 
149 type InfoQ          = Q Info
150hunk ./Language/Haskell/TH/Lib.hs 39
151 type InlineSpecQ    = Q InlineSpec
152 
153 ----------------------------------------------------------
154--- Lowercase pattern syntax functions
155+-- * Lowercase pattern syntax functions
156 ----------------------------------------------------------
157 
158 intPrimL    :: Integer -> Lit
159hunk ./Language/Haskell/TH/Lib.hs 100
160 
161 
162 -------------------------------------------------------------------------------
163---     Stmt
164+-- *   Stmt
165 
166 bindS :: PatQ -> ExpQ -> StmtQ
167 bindS p e = liftM2 BindS p e
168hunk ./Language/Haskell/TH/Lib.hs 115
169 parS _ = fail "No parallel comprehensions yet"
170 
171 -------------------------------------------------------------------------------
172---     Range
173+-- *   Range
174 
175 fromR :: ExpQ -> RangeQ
176 fromR x = do { a <- x; return (FromR a) } 
177hunk ./Language/Haskell/TH/Lib.hs 130
178 fromThenToR x y z = do { a <- x; b <- y; c <- z;
179                          return (FromThenToR a b c) } 
180 -------------------------------------------------------------------------------
181---     Body
182+-- *   Body
183 
184 normalB :: ExpQ -> BodyQ
185 normalB e = do { e1 <- e; return (NormalB e1) }
186hunk ./Language/Haskell/TH/Lib.hs 139
187 guardedB ges = do { ges' <- sequence ges; return (GuardedB ges') }
188 
189 -------------------------------------------------------------------------------
190---     Guard
191+-- *   Guard
192 
193 normalG :: ExpQ -> GuardQ
194 normalG e = do { e1 <- e; return (NormalG e1) }
195hunk ./Language/Haskell/TH/Lib.hs 156
196                   return (PatG ss', e') }
197 
198 -------------------------------------------------------------------------------
199---     Match and Clause
200+-- *   Match and Clause
201 
202hunk ./Language/Haskell/TH/Lib.hs 158
203+-- | Use with 'caseE'
204 match :: PatQ -> BodyQ -> [DecQ] -> MatchQ
205 match p rhs ds = do { p' <- p;
206                       r' <- rhs;
207hunk ./Language/Haskell/TH/Lib.hs 165
208                       ds' <- sequence ds;
209                       return (Match p' r' ds') }
210 
211+-- | Use with 'funD'
212 clause :: [PatQ] -> BodyQ -> [DecQ] -> ClauseQ
213 clause ps r ds = do { ps' <- sequence ps;
214                       r' <- r;
215hunk ./Language/Haskell/TH/Lib.hs 174
216 
217 
218 ---------------------------------------------------------------------------
219---     Exp
220+-- *   Exp
221 
222hunk ./Language/Haskell/TH/Lib.hs 176
223+-- | Dynamically binding a variable (unhygenic)
224 dyn :: String -> Q Exp
225 dyn s = return (VarE (mkName s))
226 
227hunk ./Language/Haskell/TH/Lib.hs 216
228                e' <- e
229                return (LamE ps' e')
230 
231-lam1E :: PatQ -> ExpQ -> ExpQ    -- Single-arg lambda
232+-- | Single-arg lambda
233+lam1E :: PatQ -> ExpQ -> ExpQ
234 lam1E p e = lamE [p] e
235 
236 tupE :: [ExpQ] -> ExpQ
237hunk ./Language/Haskell/TH/Lib.hs 241
238 arithSeqE :: RangeQ -> ExpQ
239 arithSeqE r = do { r' <- r; return (ArithSeqE r') } 
240 
241--- arithSeqE Shortcuts
242-fromE :: ExpQ -> ExpQ
243-fromE x = do { a <- x; return (ArithSeqE (FromR a)) } 
244-
245-fromThenE :: ExpQ -> ExpQ -> ExpQ
246-fromThenE x y = do { a <- x; b <- y; return (ArithSeqE (FromThenR a b)) } 
247-
248-fromToE :: ExpQ -> ExpQ -> ExpQ
249-fromToE x y = do { a <- x; b <- y; return (ArithSeqE (FromToR a b)) } 
250-
251-fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
252-fromThenToE x y z = do { a <- x; b <- y; c <- z;
253-                         return (ArithSeqE (FromThenToR a b c)) } 
254--- End arithSeqE shortcuts
255-
256 listE :: [ExpQ] -> ExpQ
257 listE es = do { es1 <- sequence es; return (ListE es1) }
258 
259hunk ./Language/Haskell/TH/Lib.hs 259
260 fieldExp :: Name -> ExpQ -> Q (Name, Exp)
261 fieldExp s e = do { e' <- e; return (s,e') }
262 
263+-- ** 'arithSeqE' Shortcuts
264+fromE :: ExpQ -> ExpQ
265+fromE x = do { a <- x; return (ArithSeqE (FromR a)) } 
266+
267+fromThenE :: ExpQ -> ExpQ -> ExpQ
268+fromThenE x y = do { a <- x; b <- y; return (ArithSeqE (FromThenR a b)) } 
269+
270+fromToE :: ExpQ -> ExpQ -> ExpQ
271+fromToE x y = do { a <- x; b <- y; return (ArithSeqE (FromToR a b)) } 
272+
273+fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
274+fromThenToE x y z = do { a <- x; b <- y; c <- z;
275+                         return (ArithSeqE (FromThenToR a b c)) } 
276+
277+
278 -------------------------------------------------------------------------------
279hunk ./Language/Haskell/TH/Lib.hs 275
280---     Dec
281+-- *   Dec
282 
283 valD :: PatQ -> BodyQ -> [DecQ] -> DecQ
284 valD p b ds =
285hunk ./Language/Haskell/TH/Lib.hs 411
286 
287 
288 -------------------------------------------------------------------------------
289---     Type
290+-- *   Type
291 
292 forallT :: [TyVarBndr] -> CxtQ -> TypeQ -> TypeQ
293 forallT tvars ctxt ty = do
294hunk ./Language/Haskell/TH/Lib.hs 458
295                         return (v, s, t)
296 
297 -------------------------------------------------------------------------------
298---     Kind
299+-- *   Kind
300 
301 plainTV :: Name -> TyVarBndr
302 plainTV = PlainTV
303hunk ./Language/Haskell/TH/Lib.hs 473
304 arrowK = ArrowK
305 
306 -------------------------------------------------------------------------------
307---     Callconv
308+-- *   Callconv
309 
310 cCall, stdCall :: Callconv
311 cCall = CCall
312hunk ./Language/Haskell/TH/Lib.hs 480
313 stdCall = StdCall
314 
315 -------------------------------------------------------------------------------
316---     Safety
317+-- *   Safety
318 
319 unsafe, safe, threadsafe :: Safety
320 unsafe = Unsafe
321hunk ./Language/Haskell/TH/Lib.hs 488
322 threadsafe = Threadsafe
323 
324 -------------------------------------------------------------------------------
325---     InlineSpec
326+-- *   InlineSpec
327 
328 inlineSpecNoPhase :: Bool -> Bool -> InlineSpecQ
329 inlineSpecNoPhase inline conlike
330hunk ./Language/Haskell/TH/Lib.hs 499
331   = return $ InlineSpec inline conlike (Just (beforeFrom, phase))
332 
333 -------------------------------------------------------------------------------
334---     FunDep
335+-- *   FunDep
336 
337 funDep :: [Name] -> [Name] -> FunDep
338 funDep = FunDep
339hunk ./Language/Haskell/TH/Lib.hs 505
340 
341 -------------------------------------------------------------------------------
342---     FamFlavour
343+-- *   FamFlavour
344 
345 typeFam, dataFam :: FamFlavour
346 typeFam = TypeFam
347hunk ./Language/Haskell/TH/Lib.hs 512
348 dataFam = DataFam
349 
350 --------------------------------------------------------------
351--- Useful helper functions
352+-- * Useful helper functions
353 
354 combine :: [([(Name, Name)], Pat)] -> ([(Name, Name)], [Pat])
355 combine pairs = foldr f ([],[]) pairs
356hunk ./Language/Haskell/TH/Lib.hs 550
357                Nothing -> varE s
358 
359 appsE :: [ExpQ] -> ExpQ
360-appsE [] = error "appsExp []"
361+appsE [] = error "appsE []"
362 appsE [x] = x
363 appsE (x:y:zs) = appsE ( (appE x y) : zs )
364 
365hunk ./Language/Haskell/TH/Ppr.hs 1
366--- TH.Ppr contains a prettyprinter for the
367+-- | contains a prettyprinter for the
368 -- Template Haskell datatypes
369 
370 module Language.Haskell.TH.Ppr where
371hunk ./Language/Haskell/TH/PprLib.hs 2
372 
373--- Monadic front-end to Text.PrettyPrint.HughesPJ
374+-- | Monadic front-end to Text.PrettyPrint.HughesPJ
375 
376 module Language.Haskell.TH.PprLib (
377 
378hunk ./Language/Haskell/TH/Syntax.hs 29
379        report, recover, reify,
380        location, runIO,
381 
382-       -- Names
383+       -- * Names
384        Name(..), mkName, newName, nameBase, nameModule,
385         showName, showName', NameIs(..),
386 
387hunk ./Language/Haskell/TH/Syntax.hs 33
388-       -- The algebraic data types
389+       -- * The algebraic data types
390        Dec(..), Exp(..), Con(..), Type(..), TyVarBndr(..), Kind(..),Cxt,
391        Pred(..), Match(..),  Clause(..), Body(..), Guard(..), Stmt(..),
392        Range(..), Lit(..), Pat(..), FieldExp, FieldPat,
393hunk ./Language/Haskell/TH/Syntax.hs 42
394        Info(..), Loc(..), CharPos,
395        Fixity(..), FixityDirection(..), defaultFixity, maxPrecedence,
396 
397-       -- Internal functions
398+       -- * Internal functions
399        returnQ, bindQ, sequenceQ,
400        NameFlavour(..), NameSpace (..),
401        mkNameG_v, mkNameG_d, mkNameG_tc, Uniq, mkNameL, mkNameU,
402hunk ./Language/Haskell/TH/Syntax.hs 70
403 -----------------------------------------------------
404 
405 class (Monad m, Functor m) => Quasi m where
406-       -- Fresh names
407   qNewName :: String -> m Name
408hunk ./Language/Haskell/TH/Syntax.hs 71
409+       -- ^ Fresh names
410 
411        -- Error reporting and recovery
412hunk ./Language/Haskell/TH/Syntax.hs 74
413-  qReport  :: Bool -> String -> m ()   -- Report an error (True) or warning (False)
414+  qReport  :: Bool -> String -> m ()   -- ^ Report an error (True) or warning (False)
415                                        -- ...but carry on; use 'fail' to stop
416hunk ./Language/Haskell/TH/Syntax.hs 76
417-  qRecover :: m a -> m a -> m a                -- Recover from the monadic 'fail'
418-                                       -- The first arg is the error handler
419+  qRecover :: m a -- ^ the error handler
420+           -> m a -- ^ action which may fail
421+           -> m a              -- ^ Recover from the monadic 'fail'
422 
423        -- Inspect the type-checker's environment
424   qReify :: Name -> m Info
425hunk ./Language/Haskell/TH/Syntax.hs 84
426   qLocation :: m Loc
427 
428-       -- Input/output (dangerous)
429   qRunIO :: IO a -> m a
430hunk ./Language/Haskell/TH/Syntax.hs 85
431+  -- ^ Input/output (dangerous)
432 
433 
434 -----------------------------------------------------
435hunk ./Language/Haskell/TH/Syntax.hs 151
436 report  :: Bool -> String -> Q ()
437 report b s = Q (qReport b s)
438 
439-recover :: Q a -> Q a -> Q a
440+recover :: Q a -- ^ recover with this one
441+        -> Q a -- ^ failing action
442+        -> Q a
443 recover (Q r) (Q m) = Q (qRecover r m)
444 
445 -- | 'reify' looks up information about the 'Name'
446hunk ./Language/Haskell/TH/Syntax.hs 317
447 --              Names
448 -----------------------------------------------------
449 
450--- For "global" names (NameG) we need a totally unique name,
451+-- |
452+-- For "global" names ('NameG') we need a totally unique name,
453 -- so we must include the name-space of the thing
454 --
455hunk ./Language/Haskell/TH/Syntax.hs 321
456--- For unique-numbered things (NameU), we've got a unique reference
457+-- For unique-numbered things ('NameU'), we've got a unique reference
458 -- anyway, so no need for name space
459 --
460hunk ./Language/Haskell/TH/Syntax.hs 324
461--- For dynamically bound thing (NameS) we probably want them to
462+-- For dynamically bound thing ('NameS') we probably want them to
463 -- in a context-dependent way, so again we don't want the name
464 -- space.  For example:
465hunk ./Language/Haskell/TH/Syntax.hs 327
466---     let v = mkName "T" in [| data $v = $v |]
467+--
468+-- > let v = mkName "T" in [| data $v = $v |]
469+--
470 -- Here we use the same Name for both type constructor and data constructor
471hunk ./Language/Haskell/TH/Syntax.hs 331
472-
473+--
474+--
475+-- NameL and NameG are bound *outside* the TH syntax tree
476+-- either globally (NameG) or locally (NameL). Ex:
477+--
478+-- > f x = $(h [| (map, x) |])
479+--
480+-- The 'map' will be a NameG, and 'x' wil be a NameL
481+--
482+-- These Names should never appear in a binding position in a TH syntax tree
483 data Name = Name OccName NameFlavour deriving (Typeable, Data)
484 
485 data NameFlavour
486hunk ./Language/Haskell/TH/Syntax.hs 344
487-  = NameS                      -- An unqualified name; dynamically bound
488-  | NameQ ModName              -- A qualified name; dynamically bound
489+  = NameS           -- ^ An unqualified name; dynamically bound
490+  | NameQ ModName   -- ^ A qualified name; dynamically bound
491 
492hunk ./Language/Haskell/TH/Syntax.hs 347
493-  | NameU Int#                 -- A unique local name
494+  | NameU Int#      -- ^ A unique local name
495 
496hunk ./Language/Haskell/TH/Syntax.hs 349
497-       -- The next two are for lexically-scoped names that
498-       -- are bound *outside* the TH syntax tree,
499-       -- either globally (NameG) or locally (NameL)
500-       -- e.g. f x = $(h [| (map, x) |]
501-       --      The 'map' will be a NameG, and 'x' wil be a NameL
502-       -- These Names should never appear in a binding position in a TH syntax tree
503 
504hunk ./Language/Haskell/TH/Syntax.hs 350
505-  | NameL Int#                 --
506-  | NameG NameSpace PkgName ModName    -- An original name (occurrences only, not binders)
507+  | NameL Int#      -- ^ Local name bound outside of the TH AST
508+  | NameG NameSpace PkgName ModName -- ^ Global name bound outside of the TH AST:
509+                -- An original name (occurrences only, not binders)
510+                --
511                                -- Need the namespace too to be sure which
512                                -- thing we are naming
513   deriving ( Typeable )
514hunk ./Language/Haskell/TH/Syntax.hs 358
515 
516+-- |
517 -- Although the NameFlavour type is abstract, the Data instance is not. The reason for this
518 -- is that currently we use Data to serialize values in annotations, and in order for that to
519 -- work for Template Haskell names introduced via the 'x syntax we need gunfold on NameFlavour
520hunk ./Language/Haskell/TH/Syntax.hs 401
521                             [con_NameS, con_NameQ, con_NameU,
522                              con_NameL, con_NameG]
523 
524-data NameSpace = VarName       -- Variables
525-              | DataName       -- Data constructors
526-              | TcClsName      -- Type constructors and classes; Haskell has them
527+data NameSpace = VarName       -- ^ Variables
528+              | DataName       -- ^ Data constructors
529+              | TcClsName      -- ^ Type constructors and classes; Haskell has them
530                                -- in the same name space for now.
531               deriving( Eq, Ord, Data, Typeable )
532 
533hunk ./Language/Haskell/TH/Syntax.hs 409
534 type Uniq = Int
535 
536+-- | Base, unqualified name.
537 nameBase :: Name -> String
538 nameBase (Name occ _) = occString occ
539 
540hunk ./Language/Haskell/TH/Syntax.hs 419
541 nameModule _                      = Nothing
542 
543 mkName :: String -> Name
544--- The string can have a '.', thus "Foo.baz",
545+-- ^ The string can have a '.', thus "Foo.baz",
546 -- giving a dynamically-bound qualified name,
547 -- in which case we want to generate a NameQ
548 --
549hunk ./Language/Haskell/TH/Syntax.hs 426
550 -- Parse the string to see if it has a "." in it
551 -- so we know whether to generate a qualified or unqualified name
552 -- It's a bit tricky because we need to parse
553---     Foo.Baz.x as Qual Foo.Baz x
554+--
555+-- > Foo.Baz.x   as    Qual Foo.Baz x
556+--
557 -- So we parse it from back to front
558 mkName str
559   = split [] (reverse str)
560hunk ./Language/Haskell/TH/Syntax.hs 445
561        -- This rather bizarre case actually happened; (.&.) is in Data.Bits
562     split occ (c:rev)   = split (c:occ) rev
563 
564-mkNameU :: String -> Uniq -> Name      -- Only used internally
565+-- | Only used internally
566+mkNameU :: String -> Uniq -> Name
567 mkNameU s (I# u) = Name (mkOccName s) (NameU u)
568 
569hunk ./Language/Haskell/TH/Syntax.hs 449
570-mkNameL :: String -> Uniq -> Name      -- Only used internally
571+-- | Only used internally
572+mkNameL :: String -> Uniq -> Name
573 mkNameL s (I# u) = Name (mkOccName s) (NameL u)
574 
575hunk ./Language/Haskell/TH/Syntax.hs 453
576-mkNameG :: NameSpace -> String -> String -> String -> Name     -- Used for 'x etc, but not available
577-mkNameG ns pkg modu occ                                        -- to the programmer
578+-- | Used for 'x etc, but not available to the programmer
579+mkNameG :: NameSpace -> String -> String -> String -> Name
580+mkNameG ns pkg modu occ
581   = Name (mkOccName occ) (NameG ns (mkPkgName pkg) (mkModName modu))
582 
583 mkNameG_v, mkNameG_tc, mkNameG_d :: String -> String -> String -> Name
584hunk ./Language/Haskell/TH/Syntax.hs 546
585   show = showName
586 
587 --     Tuple data and type constructors
588-tupleDataName  :: Int -> Name  -- Data constructor
589-tupleTypeName :: Int -> Name   -- Type constructor
590+tupleDataName :: Int -> Name    -- ^ Data constructor
591+tupleTypeName :: Int -> Name    -- ^ Type constructor
592 
593 tupleDataName 0 = mk_tup_name 0 DataName
594 tupleDataName 1 = error "tupleDataName 1"
595hunk ./Language/Haskell/TH/Syntax.hs 587
596 --
597 -----------------------------------------------------
598 
599-data Info
600+-- | Obtained from 'reify' in the 'Q' Monad.
601+data Info
602   = ClassI Dec
603   | ClassOpI
604        Name    -- The class op itself
605hunk ./Language/Haskell/TH/Syntax.hs 643
606 
607 data Lit = CharL Char
608          | StringL String
609-         | IntegerL Integer     -- Used for overloaded and non-overloaded
610+         | IntegerL Integer     -- ^ Used for overloaded and non-overloaded
611                                 -- literals. We don't have a good way to
612                                 -- represent non-overloaded literals at
613                                 -- the moment. Maybe that doesn't matter?
614hunk ./Language/Haskell/TH/Syntax.hs 658
615     -- but that could complicate the
616     -- suppposedly-simple TH.Syntax literal type
617 
618+-- | Pattern in Haskell given in @{}@
619 data Pat
620hunk ./Language/Haskell/TH/Syntax.hs 660
621-  = LitP Lit                      -- { 5 or 'c' }
622-  | VarP Name                     -- { x }
623-  | TupP [Pat]                    -- { (p1,p2) }
624-  | ConP Name [Pat]               -- data T1 = C1 t1 t2; {C1 p1 p1} = e
625-  | InfixP Pat Name Pat           -- foo ({x :+ y}) = e
626-  | TildeP Pat                    -- { ~p }
627-  | BangP Pat                     -- { !p }
628-  | AsP Name Pat                  -- { x @ p }
629-  | WildP                         -- { _ }
630-  | RecP Name [FieldPat]          -- f (Pt { pointx = x }) = g x
631-  | ListP [ Pat ]                 -- { [1,2,3] }
632-  | SigP Pat Type                 -- { p :: t }
633+  = LitP Lit                      -- ^ @{ 5 or 'c' }@
634+  | VarP Name                     -- ^ @{ x }@
635+  | TupP [Pat]                    -- ^ @{ (p1,p2) }@
636+  | ConP Name [Pat]               -- ^ @data T1 = C1 t1 t2; {C1 p1 p1} = e@
637+  | InfixP Pat Name Pat           -- ^ @foo ({x :+ y}) = e@
638+  | TildeP Pat                    -- ^ @{ ~p }@
639+  | BangP Pat                     -- ^ @{ !p }@
640+  | AsP Name Pat                  -- ^ @{ x \@ p }@
641+  | WildP                         -- ^ @{ _ }@
642+  | RecP Name [FieldPat]          -- ^ @f (Pt { pointx = x }) = g x@
643+  | ListP [ Pat ]                 -- ^ @{ [1,2,3] }@
644+  | SigP Pat Type                 -- ^ @{ p :: t }@
645   deriving( Show, Eq, Data, Typeable )
646 
647 type FieldPat = (Name,Pat)
648hunk ./Language/Haskell/TH/Syntax.hs 676
649 
650-data Match = Match Pat Body [Dec]
651-                                    -- case e of { pat -> body where decs }
652+data Match = Match Pat Body [Dec] -- ^ @case e of { pat -> body where decs }@
653     deriving( Show, Eq, Data, Typeable )
654 data Clause = Clause [Pat] Body [Dec]
655hunk ./Language/Haskell/TH/Syntax.hs 679
656-                                    -- f { p1 p2 = body where decs }
657+                                  -- ^ @f { p1 p2 = body where decs }@
658     deriving( Show, Eq, Data, Typeable )
659 
660 -- | The 'CompE' constructor represents a list comprehension, and
661hunk ./Language/Haskell/TH/Syntax.hs 685
662 -- takes a ['Stmt'].  The result expression of the comprehension is
663 -- the *last* of these, and should be a 'NoBindS'.
664--- E.g. [ f x | x <- xs ] is represented by
665---   CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))]
666+--
667+-- E.g. translation:
668+--
669+-- > [ f x | x <- xs ]
670+--
671+-- > CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))]
672 data Exp
673hunk ./Language/Haskell/TH/Syntax.hs 692
674-  = VarE Name                          -- { x }
675-  | ConE Name                          -- data T1 = C1 t1 t2; p = {C1} e1 e2 
676-  | LitE Lit                           -- { 5 or 'c'}
677-  | AppE Exp Exp                       -- { f x }
678+  = VarE Name                          -- ^ @{ x }@
679+  | ConE Name                          -- ^ @data T1 = C1 t1 t2; p = {C1} e1 e2  @
680+  | LitE Lit                           -- ^ @{ 5 or 'c'}@
681+  | AppE Exp Exp                       -- ^ @{ f x }@
682 
683hunk ./Language/Haskell/TH/Syntax.hs 697
684-  | InfixE (Maybe Exp) Exp (Maybe Exp) -- {x + y} or {(x+)} or {(+ x)} or {(+)}
685+  | InfixE (Maybe Exp) Exp (Maybe Exp) -- ^ @{x + y} or {(x+)} or {(+ x)} or {(+)}@
686+    --
687     -- It's a bit gruesome to use an Exp as the
688     -- operator, but how else can we distinguish
689     -- constructors from non-constructors?
690hunk ./Language/Haskell/TH/Syntax.hs 705
691     -- Maybe there should be a var-or-con type?
692     -- Or maybe we should leave it to the String itself?
693 
694-  | LamE [Pat] Exp                     -- { \ p1 p2 -> e }
695-  | TupE [Exp]                         -- { (e1,e2) } 
696-  | CondE Exp Exp Exp                  -- { if e1 then e2 else e3 }
697-  | LetE [Dec] Exp                     -- { let x=e1;   y=e2 in e3 }
698-  | CaseE Exp [Match]                  -- { case e of m1; m2 }
699-  | DoE [Stmt]                         -- { do { p <- e1; e2 }  }
700-  | CompE [Stmt]                       -- { [ (x,y) | x <- xs, y <- ys ] }
701-  | ArithSeqE Range                    -- { [ 1 ,2 .. 10 ] }
702-  | ListE [ Exp ]                      -- { [1,2,3] }
703-  | SigE Exp Type                      -- { e :: t }
704-  | RecConE Name [FieldExp]            -- { T { x = y, z = w } }
705-  | RecUpdE Exp [FieldExp]             -- { (f x) { z = w } }
706+  | LamE [Pat] Exp                     -- ^ @{ \ p1 p2 -> e }@
707+  | TupE [Exp]                         -- ^ @{ (e1,e2) }  @
708+  | CondE Exp Exp Exp                  -- ^ @{ if e1 then e2 else e3 }@
709+  | LetE [Dec] Exp                     -- ^ @{ let x=e1;   y=e2 in e3 }@
710+  | CaseE Exp [Match]                  -- ^ @{ case e of m1; m2 }@
711+  | DoE [Stmt]                         -- ^ @{ do { p <- e1; e2 }  }@
712+  | CompE [Stmt]                       -- ^ @{ [ (x,y) | x <- xs, y <- ys ] }@
713+  | ArithSeqE Range                    -- ^ @{ [ 1 ,2 .. 10 ] }@
714+  | ListE [ Exp ]                      -- ^ @{ [1,2,3] }@
715+  | SigE Exp Type                      -- ^ @{ e :: t }@
716+  | RecConE Name [FieldExp]            -- ^ @{ T { x = y, z = w } }@
717+  | RecUpdE Exp [FieldExp]             -- ^ @{ (f x) { z = w } }@
718   deriving( Show, Eq, Data, Typeable )
719 
720 type FieldExp = (Name,Exp)
721hunk ./Language/Haskell/TH/Syntax.hs 724
722 -- Omitted: implicit parameters
723 
724 data Body
725-  = GuardedB [(Guard,Exp)]   -- f p { | e1 = e2 | e3 = e4 } where ds
726-  | NormalB Exp              -- f p { = e } where ds
727+  = GuardedB [(Guard,Exp)]   -- ^ @f p { | e1 = e2 | e3 = e4 } where ds@
728+  | NormalB Exp              -- ^ @f p { = e } where ds@
729   deriving( Show, Eq, Data, Typeable )
730 
731 data Guard
732hunk ./Language/Haskell/TH/Syntax.hs 745
733           deriving( Show, Eq, Data, Typeable )
734   
735 data Dec
736-  = FunD Name [Clause]            -- { f p1 p2 = b where decs }
737-  | ValD Pat Body [Dec]           -- { p = b where decs }
738+  = FunD Name [Clause]            -- ^ @{ f p1 p2 = b where decs }@
739+  | ValD Pat Body [Dec]           -- ^ @{ p = b where decs }@
740   | DataD Cxt Name [TyVarBndr]
741hunk ./Language/Haskell/TH/Syntax.hs 748
742-         [Con] [Name]             -- { data Cxt x => T x = A x | B (T x)
743-                                  --       deriving (Z,W)}
744+         [Con] [Name]             -- ^ @{ data Cxt x => T x = A x | B (T x)
745+                                  --       deriving (Z,W)}@
746   | NewtypeD Cxt Name [TyVarBndr]
747hunk ./Language/Haskell/TH/Syntax.hs 751
748-         Con [Name]               -- { newtype Cxt x => T x = A (B x)
749-                                  --       deriving (Z,W)}
750-  | TySynD Name [TyVarBndr] Type  -- { type T x = (x,x) }
751+         Con [Name]               -- ^ @{ newtype Cxt x => T x = A (B x)
752+                                  --       deriving (Z,W)}@
753+  | TySynD Name [TyVarBndr] Type  -- ^ @{ type T x = (x,x) }@
754   | ClassD Cxt Name [TyVarBndr]
755hunk ./Language/Haskell/TH/Syntax.hs 755
756-         [FunDep] [Dec]           -- { class Eq a => Ord a where ds }
757-  | InstanceD Cxt Type [Dec]      -- { instance Show w => Show [w]
758-                                  --       where ds }
759-  | SigD Name Type                -- { length :: [a] -> Int }
760+         [FunDep] [Dec]           -- ^ @{ class Eq a => Ord a where ds }@
761+  | InstanceD Cxt Type [Dec]      -- ^ @{ instance Show w => Show [w]
762+                                  --       where ds }@
763+  | SigD Name Type                -- ^ @{ length :: [a] -> Int }@
764   | ForeignD Foreign
765hunk ./Language/Haskell/TH/Syntax.hs 760
766-  -- pragmas
767-  | PragmaD Pragma                -- { {-# INLINE [1] foo #-} }
768-  -- type families (may also appear in [Dec] of 'ClassD' and 'InstanceD')
769+
770+  -- | pragmas
771+  | PragmaD Pragma                -- ^ @{ {-# INLINE [1] foo #-} }@
772+
773+  -- | type families (may also appear in [Dec] of 'ClassD' and 'InstanceD')
774   | FamilyD FamFlavour Name
775hunk ./Language/Haskell/TH/Syntax.hs 766
776-         [TyVarBndr] (Maybe Kind) -- { type family T a b c :: * }
777+         [TyVarBndr] (Maybe Kind) -- ^ @{ type family T a b c :: * }@
778                                 
779   | DataInstD Cxt Name [Type]
780hunk ./Language/Haskell/TH/Syntax.hs 769
781-         [Con] [Name]             -- { data instance Cxt x => T [x] = A x
782+         [Con] [Name]             -- ^ @{ data instance Cxt x => T [x] = A x
783                                   --                                | B (T x)
784hunk ./Language/Haskell/TH/Syntax.hs 771
785-                                  --       deriving (Z,W)}
786+                                  --       deriving (Z,W)}@
787   | NewtypeInstD Cxt Name [Type]
788hunk ./Language/Haskell/TH/Syntax.hs 773
789-         Con [Name]               -- { newtype instance Cxt x => T [x] = A (B x)
790-                                  --       deriving (Z,W)}
791-  | TySynInstD Name [Type] Type   -- { type instance T (Maybe x) = (x,x) }
792+         Con [Name]               -- ^ @{ newtype instance Cxt x => T [x] = A (B x)
793+                                  --       deriving (Z,W)}@
794+  | TySynInstD Name [Type] Type   -- ^ @{ type instance T (Maybe x) = (x,x) }@
795   deriving( Show, Eq, Data, Typeable )
796 
797 data FunDep = FunDep [Name] [Name]
798hunk ./Language/Haskell/TH/Syntax.hs 804
799                (Maybe (Bool, Int))  -- False: before phase; True: from phase
800   deriving( Show, Eq, Data, Typeable )
801 
802-type Cxt = [Pred]                 -- (Eq a, Ord b)
803+type Cxt = [Pred]                 -- ^ @(Eq a, Ord b)@
804 
805hunk ./Language/Haskell/TH/Syntax.hs 806
806-data Pred = ClassP Name [Type]    -- Eq (Int, a)
807-          | EqualP Type Type      -- F a ~ Bool
808+data Pred = ClassP Name [Type]    -- ^ @Eq (Int, a)@
809+          | EqualP Type Type      -- ^ @F a ~ Bool@
810           deriving( Show, Eq, Data, Typeable )
811 
812 data Strict = IsStrict | NotStrict
813hunk ./Language/Haskell/TH/Syntax.hs 813
814          deriving( Show, Eq, Data, Typeable )
815 
816-data Con = NormalC Name [StrictType]          -- C Int a
817-         | RecC Name [VarStrictType]          -- C { v :: Int, w :: a }
818-         | InfixC StrictType Name StrictType  -- Int :+ a
819-         | ForallC [TyVarBndr] Cxt Con        -- forall a. Eq a => C [a]
820+data Con = NormalC Name [StrictType]          -- ^ @C Int a@
821+         | RecC Name [VarStrictType]          -- ^ @C { v :: Int, w :: a }@
822+         | InfixC StrictType Name StrictType  -- ^ @Int :+ a@
823+         | ForallC [TyVarBndr] Cxt Con        -- ^ @forall a. Eq a => C [a]@
824          deriving( Show, Eq, Data, Typeable )
825 
826 type StrictType = (Strict, Type)
827hunk ./Language/Haskell/TH/Syntax.hs 822
828 type VarStrictType = (Name, Strict, Type)
829 
830-data Type = ForallT [TyVarBndr] Cxt Type  -- forall <vars>. <ctxt> -> <type>
831-          | VarT Name                     -- a
832-          | ConT Name                     -- T
833-          | TupleT Int                    -- (,), (,,), etc.
834-          | ArrowT                        -- ->
835-          | ListT                         -- []
836-          | AppT Type Type                -- T a b
837-          | SigT Type Kind                -- t :: k
838+data Type = ForallT [TyVarBndr] Cxt Type  -- ^ @forall <vars>. <ctxt> -> <type>@
839+          | VarT Name                     -- ^ @a@
840+          | ConT Name                     -- ^ @T@
841+          | TupleT Int                    -- ^ @(,), (,,), etc.@
842+          | ArrowT                        -- ^ @->@
843+          | ListT                         -- ^ @[]@
844+          | AppT Type Type                -- ^ @T a b@
845+          | SigT Type Kind                -- ^ @t :: k@
846       deriving( Show, Eq, Data, Typeable )
847 
848hunk ./Language/Haskell/TH/Syntax.hs 832
849-data TyVarBndr = PlainTV  Name            -- a
850-               | KindedTV Name Kind       -- (a :: k)
851+data TyVarBndr = PlainTV  Name            -- ^ @a@
852+               | KindedTV Name Kind       -- ^ @(a :: k)@
853       deriving( Show, Eq, Data, Typeable )
854 
855hunk ./Language/Haskell/TH/Syntax.hs 836
856-data Kind = StarK                         -- '*'
857-          | ArrowK Kind Kind              -- k1 -> k2
858+data Kind = StarK                         -- ^ @'*'@
859+          | ArrowK Kind Kind              -- ^ @k1 -> k2@
860       deriving( Show, Eq, Data, Typeable )
861 
862 -----------------------------------------------------
863}
864[Document Info with named fields.
865Adam Vogt <vogt.adam@gmail.com>**20100427040647
866 Ignore-this: a342a367570be4f4e04e3d964b70b10a
867] {
868hunk ./Language/Haskell/TH/Syntax.hs 590
869 -- | Obtained from 'reify' in the 'Q' Monad.
870 data Info
871   = ClassI Dec
872-  | ClassOpI
873-       Name    -- The class op itself
874-       Type    -- Type of the class-op (fully polymoprhic)
875-       Name    -- Name of the parent class
876-       Fixity
877+
878+  -- | Class methods
879+  | ClassOpI {
880+    infoName            :: Name,
881+    infoTypePoly        :: Type, -- ^ Type of the class-op (fully polymorphic)
882+    infoParentClassName :: Name, -- ^ Name of the parent class
883+    infoFixity          :: Fixity
884+  }
885 
886   | TyConI Dec
887 
888hunk ./Language/Haskell/TH/Syntax.hs 601
889-  | PrimTyConI         -- Ones that can't be expressed with a data type
890-               -- decl, such as (->), Int#
891-       Name
892-       Int     -- Arity
893-       Bool    -- False => lifted type; True => unlifted
894+    -- | Ones that can't be expressed with a data type
895+    -- decl, such as (->), Int#
896+  | PrimTyConI {
897+    infoname       :: Name,
898+    infoarity      :: Int,
899+    infoisUnlifted :: Bool -- ^ False => lifted type; True => unlifted
900+    }
901 
902hunk ./Language/Haskell/TH/Syntax.hs 609
903-  | DataConI
904-       Name    -- The data con itself
905-       Type    -- Type of the constructor (fully polymorphic)
906-       Name    -- Name of the parent TyCon
907-       Fixity
908+  | DataConI {
909+    infoName            :: Name,
910+    infoTypePoly        :: Type, -- ^ Type of the constructor (fully polymorphic)
911+    infoParentTyConName :: Name, -- ^ Name of the parent TyCon
912+    infoFixity          :: Fixity
913+  }
914 
915hunk ./Language/Haskell/TH/Syntax.hs 616
916-  | VarI
917-       Name    -- The variable itself
918-       Type
919-       (Maybe Dec)     -- Nothing for lambda-bound variables, and
920-                       -- for anything else TH can't figure out
921-                       -- E.g. [| let x = 1 in $(do { d <- reify 'x; .. }) |]
922-       Fixity
923+  | VarI {
924+    infoName       :: Name,
925+    infoType       :: Type,
926+    infoDefinition :: Maybe Dec,
927+        -- ^ Nothing for lambda-bound variables, and
928+        -- for anything else TH can't figure out
929+        --
930+        -- E.g. @[| let x = 1 in $(do { d <- reify 'x; .. }) |]@
931+    infoFixity :: Fixity
932+  }
933 
934hunk ./Language/Haskell/TH/Syntax.hs 627
935-  | TyVarI     -- Scoped type variable
936-       Name
937-       Type    -- What it is bound to
938+  -- | Scoped type variable
939+  | TyVarI {
940+    infoName :: Name,
941+    infoTypeBound :: Type    -- ^ What it is bound to
942+  }
943   deriving( Show, Data, Typeable )
944 
945 data Fixity          = Fixity Int FixityDirection
946}
947
948Context:
949
950[Add parens in patterns; fix Trac #3899
951simonpj@microsoft.com**20100304132826
952 Ignore-this: a412a329e80baf7920526dc50477045a
953]
954[Add quasiquote definitions for declarations and types
955simonpj@microsoft.com**20100210094223
956 Ignore-this: 2ca1b01b586ffbe2e5076fa7bd513f3
957]
958[Tighten the base dep; fixes trac #3809
959Ian Lynagh <igloo@earth.li>**20100116221832]
960[bump base dep; apparently base4 is now required
961Ian Lynagh <igloo@earth.li>**20091215223555]
962[Fix pretty-printing of INLINE pragmas
963Roman Leshchinskiy <rl@cse.unsw.edu.au>**20091109113200
964 Ignore-this: 7c7659b58d7b5fd48e23d0e153fa0683
965]
966[Fix Trac #3572 (pls merge)
967simonpj@microsoft.com**20091015114104
968 Ignore-this: 821b6bd40fd02f13f5878c7f62284d6e
969]
970[Document 'CompE' better (see Trac #3395)
971simonpj@microsoft.com**20090813152941
972 Ignore-this: 26ceaa525269be0ea3b8128366aa2522
973]
974[Fix "Cabal check" warnings
975Ian Lynagh <igloo@earth.li>**20090811215923]
976[TAG 2009-06-25
977Ian Lynagh <igloo@earth.li>**20090625160423]
978Patch bundle hash:
9798ad9deba5c9c2a48f0231abe97eecbf954d058f5