hunk ./template-haskell.cabal 13 - build-depends: base >= 4 && < 5, + build-depends: base >= 4.2 && < 5, hunk ./Language/Haskell/TH/Lib.hs 21 +type DecsQ = Q [Dec] hunk ./Language/Haskell/TH/Quote.hs 11 -data QuasiQuoter = QuasiQuoter { quoteExp :: String -> Q Exp, - quotePat :: String -> Q Pat } +data QuasiQuoter = QuasiQuoter { quoteExp :: String -> Q Exp, + quotePat :: String -> Q Pat, + quoteType :: String -> Q Type, + quoteDec :: String -> Q [Dec] } hunk ./Language/Haskell/TH/Ppr.hs 177 -pprPat i (ConP s ps) = parensIf (i > noPrec) $ pprName' Applied s - <+> sep (map (pprPat appPrec) ps) +pprPat i (ConP s ps) = parensIf (i >= appPrec) $ pprName' Applied s + <+> sep (map (pprPat appPrec) ps) hunk ./Language/Haskell/TH/Ppr.hs 180 - = parensIf (i > noPrec) (pprPat opPrec p1 <+> - pprName' Infix n <+> - pprPat opPrec p2) + = parensIf (i >= opPrec) (pprPat opPrec p1 <+> + pprName' Infix n <+> + pprPat opPrec p2) hunk ./Language/Haskell/TH.hs 1 --- The public face of Template Haskell +{- | The public face of Template Haskell hunk ./Language/Haskell/TH.hs 3 +For other documentation, refer to: + + +-} hunk ./Language/Haskell/TH.hs 8 - -- The monad and its operations + -- * The monad and its operations hunk ./Language/Haskell/TH.hs 16 - -- Names + -- * Names hunk ./Language/Haskell/TH.hs 24 - -- The algebraic data types + -- * 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 (@$( ... )@) hunk ./Language/Haskell/TH.hs 35 - -- Library functions + -- * Library functions + -- ** Abbreviations hunk ./Language/Haskell/TH.hs 40 + + -- ** Constructors lifted to 'Q' + -- *** Litterals hunk ./Language/Haskell/TH.hs 45 + -- *** Patterns hunk ./Language/Haskell/TH.hs 49 - bindS, letS, noBindS, parS, - fromR, fromThenR, fromToR, fromThenToR, + + -- *** Pattern Guards hunk ./Language/Haskell/TH.hs 52 + + -- *** Expressions hunk ./Language/Haskell/TH.hs 55 - lamE, lam1E, tupE, condE, letE, caseE, doE, compE, arithSeqE, appsE, - fromE, fromThenE, fromToE, fromThenToE, + lamE, lam1E, tupE, condE, letE, caseE, appsE, hunk ./Language/Haskell/TH.hs 57 - valD, funD, tySynD, dataD, newtypeD, classD, instanceD, sigD, forImpD, - pragInlD, pragSpecD, familyNoKindD, familyKindD, dataInstD, - newtypeInstD, tySynInstD, - cxt, classP, equalP, normalC, recC, infixC, + -- **** Ranges + fromE, fromThenE, fromToE, fromThenToE, + + -- ***** Ranges with more indirection + arithSeqE, + fromR, fromThenR, fromToR, fromThenToR, + -- **** Statements + doE, compE, + bindS, letS, noBindS, parS, + + -- *** Types hunk ./Language/Haskell/TH.hs 69 + -- **** Strictness hunk ./Language/Haskell/TH.hs 71 - cCall, stdCall, unsafe, safe, threadsafe, - inlineSpecNoPhase, inlineSpecPhase, typeFam, dataFam, + -- **** Class Contexts + cxt, classP, equalP, normalC, recC, infixC, + + -- *** Top Level Declarations + -- **** Data + valD, funD, tySynD, dataD, newtypeD, + -- **** Class + classD, instanceD, sigD, + -- **** Type Family / Data Family + familyNoKindD, familyKindD, dataInstD, + newtypeInstD, tySynInstD, + typeFam, dataFam, + -- **** Foreign Function Interface (FFI) + cCall, stdCall, unsafe, safe, threadsafe, forImpD, + -- **** Pragmas + -- | Just inline supported so far + inlineSpecNoPhase, inlineSpecPhase, + pragInlD, pragSpecD, hunk ./Language/Haskell/TH.hs 90 - -- Pretty-printer + -- * Pretty-printer hunk ./Language/Haskell/TH/Lib.hs 1 +-- | hunk ./Language/Haskell/TH/Lib.hs 14 --- Type synonyms +-- * Type synonyms hunk ./Language/Haskell/TH/Lib.hs 39 --- Lowercase pattern syntax functions +-- * Lowercase pattern syntax functions hunk ./Language/Haskell/TH/Lib.hs 100 --- Stmt +-- * Stmt hunk ./Language/Haskell/TH/Lib.hs 115 --- Range +-- * Range hunk ./Language/Haskell/TH/Lib.hs 130 --- Body +-- * Body hunk ./Language/Haskell/TH/Lib.hs 139 --- Guard +-- * Guard hunk ./Language/Haskell/TH/Lib.hs 156 --- Match and Clause +-- * Match and Clause hunk ./Language/Haskell/TH/Lib.hs 158 +-- | Use with 'caseE' hunk ./Language/Haskell/TH/Lib.hs 165 +-- | Use with 'funD' hunk ./Language/Haskell/TH/Lib.hs 174 --- Exp +-- * Exp hunk ./Language/Haskell/TH/Lib.hs 176 +-- | Dynamically binding a variable (unhygenic) hunk ./Language/Haskell/TH/Lib.hs 216 -lam1E :: PatQ -> ExpQ -> ExpQ -- Single-arg lambda +-- | Single-arg lambda +lam1E :: PatQ -> ExpQ -> ExpQ hunk ./Language/Haskell/TH/Lib.hs 241 --- arithSeqE Shortcuts -fromE :: ExpQ -> ExpQ -fromE x = do { a <- x; return (ArithSeqE (FromR a)) } - -fromThenE :: ExpQ -> ExpQ -> ExpQ -fromThenE x y = do { a <- x; b <- y; return (ArithSeqE (FromThenR a b)) } - -fromToE :: ExpQ -> ExpQ -> ExpQ -fromToE x y = do { a <- x; b <- y; return (ArithSeqE (FromToR a b)) } - -fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ -fromThenToE x y z = do { a <- x; b <- y; c <- z; - return (ArithSeqE (FromThenToR a b c)) } --- End arithSeqE shortcuts - hunk ./Language/Haskell/TH/Lib.hs 259 +-- ** 'arithSeqE' Shortcuts +fromE :: ExpQ -> ExpQ +fromE x = do { a <- x; return (ArithSeqE (FromR a)) } + +fromThenE :: ExpQ -> ExpQ -> ExpQ +fromThenE x y = do { a <- x; b <- y; return (ArithSeqE (FromThenR a b)) } + +fromToE :: ExpQ -> ExpQ -> ExpQ +fromToE x y = do { a <- x; b <- y; return (ArithSeqE (FromToR a b)) } + +fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ +fromThenToE x y z = do { a <- x; b <- y; c <- z; + return (ArithSeqE (FromThenToR a b c)) } + + hunk ./Language/Haskell/TH/Lib.hs 275 --- Dec +-- * Dec hunk ./Language/Haskell/TH/Lib.hs 411 --- Type +-- * Type hunk ./Language/Haskell/TH/Lib.hs 458 --- Kind +-- * Kind hunk ./Language/Haskell/TH/Lib.hs 473 --- Callconv +-- * Callconv hunk ./Language/Haskell/TH/Lib.hs 480 --- Safety +-- * Safety hunk ./Language/Haskell/TH/Lib.hs 488 --- InlineSpec +-- * InlineSpec hunk ./Language/Haskell/TH/Lib.hs 499 --- FunDep +-- * FunDep hunk ./Language/Haskell/TH/Lib.hs 505 --- FamFlavour +-- * FamFlavour hunk ./Language/Haskell/TH/Lib.hs 512 --- Useful helper functions +-- * Useful helper functions hunk ./Language/Haskell/TH/Lib.hs 550 -appsE [] = error "appsExp []" +appsE [] = error "appsE []" hunk ./Language/Haskell/TH/Ppr.hs 1 --- TH.Ppr contains a prettyprinter for the +-- | contains a prettyprinter for the hunk ./Language/Haskell/TH/PprLib.hs 2 --- Monadic front-end to Text.PrettyPrint.HughesPJ +-- | Monadic front-end to Text.PrettyPrint.HughesPJ hunk ./Language/Haskell/TH/Syntax.hs 29 - -- Names + -- * Names hunk ./Language/Haskell/TH/Syntax.hs 33 - -- The algebraic data types + -- * The algebraic data types hunk ./Language/Haskell/TH/Syntax.hs 42 - -- Internal functions + -- * Internal functions hunk ./Language/Haskell/TH/Syntax.hs 70 - -- Fresh names hunk ./Language/Haskell/TH/Syntax.hs 71 + -- ^ Fresh names hunk ./Language/Haskell/TH/Syntax.hs 74 - qReport :: Bool -> String -> m () -- Report an error (True) or warning (False) + qReport :: Bool -> String -> m () -- ^ Report an error (True) or warning (False) hunk ./Language/Haskell/TH/Syntax.hs 76 - qRecover :: m a -> m a -> m a -- Recover from the monadic 'fail' - -- The first arg is the error handler + qRecover :: m a -- ^ the error handler + -> m a -- ^ action which may fail + -> m a -- ^ Recover from the monadic 'fail' hunk ./Language/Haskell/TH/Syntax.hs 84 - -- Input/output (dangerous) hunk ./Language/Haskell/TH/Syntax.hs 85 + -- ^ Input/output (dangerous) hunk ./Language/Haskell/TH/Syntax.hs 151 -recover :: Q a -> Q a -> Q a +recover :: Q a -- ^ recover with this one + -> Q a -- ^ failing action + -> Q a hunk ./Language/Haskell/TH/Syntax.hs 317 --- For "global" names (NameG) we need a totally unique name, +-- | +-- For "global" names ('NameG') we need a totally unique name, hunk ./Language/Haskell/TH/Syntax.hs 321 --- For unique-numbered things (NameU), we've got a unique reference +-- For unique-numbered things ('NameU'), we've got a unique reference hunk ./Language/Haskell/TH/Syntax.hs 324 --- For dynamically bound thing (NameS) we probably want them to +-- For dynamically bound thing ('NameS') we probably want them to hunk ./Language/Haskell/TH/Syntax.hs 327 --- let v = mkName "T" in [| data $v = $v |] +-- +-- > let v = mkName "T" in [| data $v = $v |] +-- hunk ./Language/Haskell/TH/Syntax.hs 331 - +-- +-- +-- NameL and NameG are bound *outside* the TH syntax tree +-- either globally (NameG) or locally (NameL). Ex: +-- +-- > f x = $(h [| (map, x) |]) +-- +-- The 'map' will be a NameG, and 'x' wil be a NameL +-- +-- These Names should never appear in a binding position in a TH syntax tree hunk ./Language/Haskell/TH/Syntax.hs 344 - = NameS -- An unqualified name; dynamically bound - | NameQ ModName -- A qualified name; dynamically bound + = NameS -- ^ An unqualified name; dynamically bound + | NameQ ModName -- ^ A qualified name; dynamically bound hunk ./Language/Haskell/TH/Syntax.hs 347 - | NameU Int# -- A unique local name + | NameU Int# -- ^ A unique local name hunk ./Language/Haskell/TH/Syntax.hs 349 - -- The next two are for lexically-scoped names that - -- are bound *outside* the TH syntax tree, - -- either globally (NameG) or locally (NameL) - -- e.g. f x = $(h [| (map, x) |] - -- The 'map' will be a NameG, and 'x' wil be a NameL - -- These Names should never appear in a binding position in a TH syntax tree hunk ./Language/Haskell/TH/Syntax.hs 350 - | NameL Int# -- - | NameG NameSpace PkgName ModName -- An original name (occurrences only, not binders) + | NameL Int# -- ^ Local name bound outside of the TH AST + | NameG NameSpace PkgName ModName -- ^ Global name bound outside of the TH AST: + -- An original name (occurrences only, not binders) + -- hunk ./Language/Haskell/TH/Syntax.hs 358 +-- | hunk ./Language/Haskell/TH/Syntax.hs 401 -data NameSpace = VarName -- Variables - | DataName -- Data constructors - | TcClsName -- Type constructors and classes; Haskell has them +data NameSpace = VarName -- ^ Variables + | DataName -- ^ Data constructors + | TcClsName -- ^ Type constructors and classes; Haskell has them hunk ./Language/Haskell/TH/Syntax.hs 409 +-- | Base, unqualified name. hunk ./Language/Haskell/TH/Syntax.hs 419 --- The string can have a '.', thus "Foo.baz", +-- ^ The string can have a '.', thus "Foo.baz", hunk ./Language/Haskell/TH/Syntax.hs 426 --- Foo.Baz.x as Qual Foo.Baz x +-- +-- > Foo.Baz.x as Qual Foo.Baz x +-- hunk ./Language/Haskell/TH/Syntax.hs 445 -mkNameU :: String -> Uniq -> Name -- Only used internally +-- | Only used internally +mkNameU :: String -> Uniq -> Name hunk ./Language/Haskell/TH/Syntax.hs 449 -mkNameL :: String -> Uniq -> Name -- Only used internally +-- | Only used internally +mkNameL :: String -> Uniq -> Name hunk ./Language/Haskell/TH/Syntax.hs 453 -mkNameG :: NameSpace -> String -> String -> String -> Name -- Used for 'x etc, but not available -mkNameG ns pkg modu occ -- to the programmer +-- | Used for 'x etc, but not available to the programmer +mkNameG :: NameSpace -> String -> String -> String -> Name +mkNameG ns pkg modu occ hunk ./Language/Haskell/TH/Syntax.hs 546 -tupleDataName :: Int -> Name -- Data constructor -tupleTypeName :: Int -> Name -- Type constructor +tupleDataName :: Int -> Name -- ^ Data constructor +tupleTypeName :: Int -> Name -- ^ Type constructor hunk ./Language/Haskell/TH/Syntax.hs 587 -data Info +-- | Obtained from 'reify' in the 'Q' Monad. +data Info hunk ./Language/Haskell/TH/Syntax.hs 643 - | IntegerL Integer -- Used for overloaded and non-overloaded + | IntegerL Integer -- ^ Used for overloaded and non-overloaded hunk ./Language/Haskell/TH/Syntax.hs 658 +-- | Pattern in Haskell given in @{}@ hunk ./Language/Haskell/TH/Syntax.hs 660 - = LitP Lit -- { 5 or 'c' } - | VarP Name -- { x } - | TupP [Pat] -- { (p1,p2) } - | ConP Name [Pat] -- data T1 = C1 t1 t2; {C1 p1 p1} = e - | InfixP Pat Name Pat -- foo ({x :+ y}) = e - | TildeP Pat -- { ~p } - | BangP Pat -- { !p } - | AsP Name Pat -- { x @ p } - | WildP -- { _ } - | RecP Name [FieldPat] -- f (Pt { pointx = x }) = g x - | ListP [ Pat ] -- { [1,2,3] } - | SigP Pat Type -- { p :: t } + = LitP Lit -- ^ @{ 5 or 'c' }@ + | VarP Name -- ^ @{ x }@ + | TupP [Pat] -- ^ @{ (p1,p2) }@ + | ConP Name [Pat] -- ^ @data T1 = C1 t1 t2; {C1 p1 p1} = e@ + | InfixP Pat Name Pat -- ^ @foo ({x :+ y}) = e@ + | TildeP Pat -- ^ @{ ~p }@ + | BangP Pat -- ^ @{ !p }@ + | AsP Name Pat -- ^ @{ x \@ p }@ + | WildP -- ^ @{ _ }@ + | RecP Name [FieldPat] -- ^ @f (Pt { pointx = x }) = g x@ + | ListP [ Pat ] -- ^ @{ [1,2,3] }@ + | SigP Pat Type -- ^ @{ p :: t }@ hunk ./Language/Haskell/TH/Syntax.hs 676 -data Match = Match Pat Body [Dec] - -- case e of { pat -> body where decs } +data Match = Match Pat Body [Dec] -- ^ @case e of { pat -> body where decs }@ hunk ./Language/Haskell/TH/Syntax.hs 679 - -- f { p1 p2 = body where decs } + -- ^ @f { p1 p2 = body where decs }@ hunk ./Language/Haskell/TH/Syntax.hs 685 --- E.g. [ f x | x <- xs ] is represented by --- CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))] +-- +-- E.g. translation: +-- +-- > [ f x | x <- xs ] +-- +-- > CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))] hunk ./Language/Haskell/TH/Syntax.hs 692 - = VarE Name -- { x } - | ConE Name -- data T1 = C1 t1 t2; p = {C1} e1 e2 - | LitE Lit -- { 5 or 'c'} - | AppE Exp Exp -- { f x } + = VarE Name -- ^ @{ x }@ + | ConE Name -- ^ @data T1 = C1 t1 t2; p = {C1} e1 e2 @ + | LitE Lit -- ^ @{ 5 or 'c'}@ + | AppE Exp Exp -- ^ @{ f x }@ hunk ./Language/Haskell/TH/Syntax.hs 697 - | InfixE (Maybe Exp) Exp (Maybe Exp) -- {x + y} or {(x+)} or {(+ x)} or {(+)} + | InfixE (Maybe Exp) Exp (Maybe Exp) -- ^ @{x + y} or {(x+)} or {(+ x)} or {(+)}@ + -- hunk ./Language/Haskell/TH/Syntax.hs 705 - | LamE [Pat] Exp -- { \ p1 p2 -> e } - | TupE [Exp] -- { (e1,e2) } - | CondE Exp Exp Exp -- { if e1 then e2 else e3 } - | LetE [Dec] Exp -- { let x=e1; y=e2 in e3 } - | CaseE Exp [Match] -- { case e of m1; m2 } - | DoE [Stmt] -- { do { p <- e1; e2 } } - | CompE [Stmt] -- { [ (x,y) | x <- xs, y <- ys ] } - | ArithSeqE Range -- { [ 1 ,2 .. 10 ] } - | ListE [ Exp ] -- { [1,2,3] } - | SigE Exp Type -- { e :: t } - | RecConE Name [FieldExp] -- { T { x = y, z = w } } - | RecUpdE Exp [FieldExp] -- { (f x) { z = w } } + | LamE [Pat] Exp -- ^ @{ \ p1 p2 -> e }@ + | TupE [Exp] -- ^ @{ (e1,e2) } @ + | CondE Exp Exp Exp -- ^ @{ if e1 then e2 else e3 }@ + | LetE [Dec] Exp -- ^ @{ let x=e1; y=e2 in e3 }@ + | CaseE Exp [Match] -- ^ @{ case e of m1; m2 }@ + | DoE [Stmt] -- ^ @{ do { p <- e1; e2 } }@ + | CompE [Stmt] -- ^ @{ [ (x,y) | x <- xs, y <- ys ] }@ + | ArithSeqE Range -- ^ @{ [ 1 ,2 .. 10 ] }@ + | ListE [ Exp ] -- ^ @{ [1,2,3] }@ + | SigE Exp Type -- ^ @{ e :: t }@ + | RecConE Name [FieldExp] -- ^ @{ T { x = y, z = w } }@ + | RecUpdE Exp [FieldExp] -- ^ @{ (f x) { z = w } }@ hunk ./Language/Haskell/TH/Syntax.hs 724 - = GuardedB [(Guard,Exp)] -- f p { | e1 = e2 | e3 = e4 } where ds - | NormalB Exp -- f p { = e } where ds + = GuardedB [(Guard,Exp)] -- ^ @f p { | e1 = e2 | e3 = e4 } where ds@ + | NormalB Exp -- ^ @f p { = e } where ds@ hunk ./Language/Haskell/TH/Syntax.hs 745 - = FunD Name [Clause] -- { f p1 p2 = b where decs } - | ValD Pat Body [Dec] -- { p = b where decs } + = FunD Name [Clause] -- ^ @{ f p1 p2 = b where decs }@ + | ValD Pat Body [Dec] -- ^ @{ p = b where decs }@ hunk ./Language/Haskell/TH/Syntax.hs 748 - [Con] [Name] -- { data Cxt x => T x = A x | B (T x) - -- deriving (Z,W)} + [Con] [Name] -- ^ @{ data Cxt x => T x = A x | B (T x) + -- deriving (Z,W)}@ hunk ./Language/Haskell/TH/Syntax.hs 751 - Con [Name] -- { newtype Cxt x => T x = A (B x) - -- deriving (Z,W)} - | TySynD Name [TyVarBndr] Type -- { type T x = (x,x) } + Con [Name] -- ^ @{ newtype Cxt x => T x = A (B x) + -- deriving (Z,W)}@ + | TySynD Name [TyVarBndr] Type -- ^ @{ type T x = (x,x) }@ hunk ./Language/Haskell/TH/Syntax.hs 755 - [FunDep] [Dec] -- { class Eq a => Ord a where ds } - | InstanceD Cxt Type [Dec] -- { instance Show w => Show [w] - -- where ds } - | SigD Name Type -- { length :: [a] -> Int } + [FunDep] [Dec] -- ^ @{ class Eq a => Ord a where ds }@ + | InstanceD Cxt Type [Dec] -- ^ @{ instance Show w => Show [w] + -- where ds }@ + | SigD Name Type -- ^ @{ length :: [a] -> Int }@ hunk ./Language/Haskell/TH/Syntax.hs 760 - -- pragmas - | PragmaD Pragma -- { {-# INLINE [1] foo #-} } - -- type families (may also appear in [Dec] of 'ClassD' and 'InstanceD') + + -- | pragmas + | PragmaD Pragma -- ^ @{ {-# INLINE [1] foo #-} }@ + + -- | type families (may also appear in [Dec] of 'ClassD' and 'InstanceD') hunk ./Language/Haskell/TH/Syntax.hs 766 - [TyVarBndr] (Maybe Kind) -- { type family T a b c :: * } + [TyVarBndr] (Maybe Kind) -- ^ @{ type family T a b c :: * }@ hunk ./Language/Haskell/TH/Syntax.hs 769 - [Con] [Name] -- { data instance Cxt x => T [x] = A x + [Con] [Name] -- ^ @{ data instance Cxt x => T [x] = A x hunk ./Language/Haskell/TH/Syntax.hs 771 - -- deriving (Z,W)} + -- deriving (Z,W)}@ hunk ./Language/Haskell/TH/Syntax.hs 773 - Con [Name] -- { newtype instance Cxt x => T [x] = A (B x) - -- deriving (Z,W)} - | TySynInstD Name [Type] Type -- { type instance T (Maybe x) = (x,x) } + Con [Name] -- ^ @{ newtype instance Cxt x => T [x] = A (B x) + -- deriving (Z,W)}@ + | TySynInstD Name [Type] Type -- ^ @{ type instance T (Maybe x) = (x,x) }@ hunk ./Language/Haskell/TH/Syntax.hs 804 -type Cxt = [Pred] -- (Eq a, Ord b) +type Cxt = [Pred] -- ^ @(Eq a, Ord b)@ hunk ./Language/Haskell/TH/Syntax.hs 806 -data Pred = ClassP Name [Type] -- Eq (Int, a) - | EqualP Type Type -- F a ~ Bool +data Pred = ClassP Name [Type] -- ^ @Eq (Int, a)@ + | EqualP Type Type -- ^ @F a ~ Bool@ hunk ./Language/Haskell/TH/Syntax.hs 813 -data Con = NormalC Name [StrictType] -- C Int a - | RecC Name [VarStrictType] -- C { v :: Int, w :: a } - | InfixC StrictType Name StrictType -- Int :+ a - | ForallC [TyVarBndr] Cxt Con -- forall a. Eq a => C [a] +data Con = NormalC Name [StrictType] -- ^ @C Int a@ + | RecC Name [VarStrictType] -- ^ @C { v :: Int, w :: a }@ + | InfixC StrictType Name StrictType -- ^ @Int :+ a@ + | ForallC [TyVarBndr] Cxt Con -- ^ @forall a. Eq a => C [a]@ hunk ./Language/Haskell/TH/Syntax.hs 822 -data Type = ForallT [TyVarBndr] Cxt Type -- forall . -> - | VarT Name -- a - | ConT Name -- T - | TupleT Int -- (,), (,,), etc. - | ArrowT -- -> - | ListT -- [] - | AppT Type Type -- T a b - | SigT Type Kind -- t :: k +data Type = ForallT [TyVarBndr] Cxt Type -- ^ @forall . -> @ + | VarT Name -- ^ @a@ + | ConT Name -- ^ @T@ + | TupleT Int -- ^ @(,), (,,), etc.@ + | ArrowT -- ^ @->@ + | ListT -- ^ @[]@ + | AppT Type Type -- ^ @T a b@ + | SigT Type Kind -- ^ @t :: k@ hunk ./Language/Haskell/TH/Syntax.hs 832 -data TyVarBndr = PlainTV Name -- a - | KindedTV Name Kind -- (a :: k) +data TyVarBndr = PlainTV Name -- ^ @a@ + | KindedTV Name Kind -- ^ @(a :: k)@ hunk ./Language/Haskell/TH/Syntax.hs 836 -data Kind = StarK -- '*' - | ArrowK Kind Kind -- k1 -> k2 +data Kind = StarK -- ^ @'*'@ + | ArrowK Kind Kind -- ^ @k1 -> k2@ hunk ./Language/Haskell/TH.hs 42 - -- *** Litterals + -- *** Literals hunk ./Language/Haskell/TH/Ppr.hs 245 - = text "data" <+> maybeInst - <+> pprCxt ctxt - <+> ppr t <+> argsDoc - <+> sep (pref $ map ppr cs) - $$ if null decs - then empty - else nest nestDepth - $ text "deriving" - <+> parens (hsep $ punctuate comma $ map ppr decs) + = sep [text "data" <+> maybeInst + <+> pprCxt ctxt + <+> ppr t <+> argsDoc, + nest nestDepth (sep (pref $ map ppr cs)), + if null decs + then empty + else nest nestDepth + $ text "deriving" + <+> parens (hsep $ punctuate comma $ map ppr decs)] hunk ./Language/Haskell/TH/Ppr.hs 261 - = text "newtype" <+> maybeInst - <+> pprCxt ctxt - <+> ppr t <+> argsDoc - <+> char '=' <+> ppr c - $$ if null decs - then empty - else nest nestDepth - $ text "deriving" - <+> parens (hsep $ punctuate comma $ map ppr decs) + = sep [text "newtype" <+> maybeInst + <+> pprCxt ctxt + <+> ppr t <+> argsDoc, + nest 2 (char '=' <+> ppr c), + if null decs + then empty + else nest nestDepth + $ text "deriving" + <+> parens (hsep $ punctuate comma $ map ppr decs)] hunk ./Language/Haskell/TH/Ppr.hs 346 - <+> char '.' <+> pprCxt ctxt <+> ppr con + <+> char '.' <+> sep [pprCxt ctxt, ppr con] hunk ./Language/Haskell/TH/Ppr.hs 372 - <+> pprCxt ctxt <+> ppr ty + <+> sep [pprCxt ctxt, ppr ty] hunk ./Language/Haskell/TH/Ppr.hs 412 -pprCxt ts = parens (hsep $ punctuate comma $ map ppr ts) <+> text "=>" +pprCxt ts = parens (sep $ punctuate comma $ map ppr ts) <+> text "=>" hunk ./Language/Haskell/TH/Lib.hs 56 +stringPrimL :: String -> Lit +stringPrimL = StringPrimL hunk ./Language/Haskell/TH/Ppr.hs 167 +pprLit _ (StringPrimL s) = text (show s) <> char '#' hunk ./Language/Haskell/TH/Syntax.hs 652 + | StringPrimL String -- ^ A primitive C-style string, type Addr#