$%      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$portable experimentallibraries@haskell.org Safe-Infered2Generate a fresh name, which cannot be captured. For example, this:   f = $(do  nm1 < - newName "x"  let nm2 =  "x"  return ( [  nm1] (LamE [VarP nm2] ( nm1)))  )will produce the splice  f = \x0 -> \x -> x0 In particular, the occurrence VarE nm1 refers to the binding VarP nm1, #and is not captured by the binding VarP nm2. Although names generated by newName cannot  be captured , they can capture! other names. For example, this:   g = $(do  nm1 <- newName "x"  let nm2 = mkName "x" 8 return (LamE [VarP nm2] (LamE [VarP nm1] (VarE nm2)))  ) will produce the splice  g = \x -> \x0 -> x0 since the occurrence VarE nm2& is captured by the innermost binding of x , namely VarP nm1. >Generate a capturable name. Occurrences of such names will be Bresolved according to the Haskell scoping rules at the occurrence site.  For example:  & f = [| pi + $(varE (mkName "pi")) |]  ...  g = let pi = 3 in $f In this case, g is desugared to   g = Prelude.pi + 3  Note that mkName# may be used with qualified names:   mkName "Prelude.pi"  See also 2 for a useful combinator. The above example could be rewritten using dyn as  f = [| pi + $(dyn "pi") |] Only used internally Pattern in Haskell given in {} 8An abstract type representing names in the syntax tree. @s can be constructed in several ways, which come with different name-capture guarantees (see &Language.Haskell.TH.Syntax#namecapture for !an explanation of name capture):  the built-in syntax 'f and ''T" can be used to construct names,  The expression 'f gives a Name which refers to the value f  currently in scope, and ''T gives a Name which refers to the  type T8 currently in scope. These names can never be captured.  s and r are similar to 'f and  ''T respectively, but the Names are looked up at the point E where the current splice is being run. These names can never be  captured.  3 monadically generates a new name, which can never  be captured.   generates a capturable name. Names constructed using newName and mkName may be used in bindings  (such as  let x = ... or x -> ...), but names constructed using lookupValueName, lookupTypeName, 'f, ''T may not. 3To avoid duplication between kinds and types, they 8 are defined to be the same. Naturally, you would never  have a type be ! and you would never have a kind  be 1, but many of the other constructors are shared.  Note that the kind Bool is denoted with , not  '. Similarly, tuple kinds are made with ,  not . Hello 2 (a :: k) a  0,1,2, etc.  Constraint * (':) '[] '(), '(,), ' (,,), etc. [] -> (,), (,,), etc. (,), (,,), etc. 'T T a t :: k T a b forall <vars>. <ctxt> -> <type> forall a. Eq a => C [a] Int :+ a C { v :: Int, w :: a } C Int a  F a ~ Bool  Eq (Int, a) %{ type instance T (Maybe x) = (x,x) }  { newtype instance Cxt x => T [x] = A (B x)  deriving (Z,W)} { data instance Cxt x => T [x] = A x * | B (T x)  deriving (Z,W)} { type family T a b c :: * } { {- INLINE [1] foo -} } { infix 3 foo } { foreign import ... } { foreign export ... } { length :: [a] -> Int } { instance Show w => Show [w]  where ds }  { class Eq a => Ord a where ds } { type T x = (x,x) } !{ newtype Cxt x => T x = A (B x)  deriving (Z,W)} ${ data Cxt x => T x = A x | B (T x)  deriving (Z,W)} { p = b where decs } { f p1 p2 = b where decs } f x { | Just y < - x, Just z < - y } = z f x { | odd x } = x f p { = e } where ds f p { | e1 = e2  | e3 = e4 }  where ds { (f x) { z = w } } { T { x = y, z = w } }  { e :: t } { [1,2,3] } { [ 1 ,2 .. 10 ] } { [ (x,y) | x <- xs, y <- ys ] }.The result expression of the comprehension is  the last of the s, and should be a . E.g. translation:   [ f x | x <- xs ] D CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))]   { do { p < - e1; e2 } } { case e of m1; m2 } { let x=e1; y=e2 in e3 } { if | g1 -> e1 | g2 -> e2 } { if e1 then e2 else e3 } { ( e1,e2 ) }  { (e1,e2) } { c ase m1; m2 } {   p1 p2 -> e }  { (e) }See  Language.Haskell.TH.Syntax#infix   {x + y}See  Language.Haskell.TH.Syntax#infix  %{x + y} or {(x+)} or {(+ x)} or {(+)} { f x } { 5 or c} "data T1 = C1 t1 t2; p = {C1} e1 e2 { x } f { p1 p2 = body where decs } $case e of { pat -> body where decs }  { e -> p }  { p :: t } { [1,2,3] } f (Pt { pointx = x }) = g x { _ } { x @ p } { !p } { ~p } {(p)}See  Language.Haskell.TH.Syntax#infix  foo ({x :+ y}) = eSee  Language.Haskell.TH.Syntax#infix  foo ({x :+ y}) = e "data T1 = C1 t1 t2; {C1 p1 p1} = e { ( p1,p2 ) }  { (p1,p2) } { x }! { 5 or c }#%A primitive C-style string, type Addr# )'Used for overloaded and non-overloaded  literals. We don't have a good way to & represent non-overloaded literals at  the moment. Maybe that doesn' t matter? 229 desribes a single instance of a class or type function.  It is just a -, but guaranteed to be one of the following:   (with empty [])   or  (with empty derived [])   3In :$, is the type constructor unlifted? 4In : , arity of the type constructor 5In = and 9#, name of the parent class or type 6Obtained from t in the ~ Monad. 7A type variable. The Type7 field contains the type which underlies the variable.  At present, this is always  theName, but future changes ! may permit refinement of this. 8A "value". variable (as opposed to a type variable, see 7). The  Maybe Dec field contains Just the declaration which C defined the variable -- including the RHS of the declaration --  or else Nothing., in the case where the RHS is unavailable to 3 the compiler. At present, this value is _always_ Nothing: < returning the RHS has not yet been implemented because of  lack of interest. 9A data constructor :A " primitive" type constructor, which can't be expressed with a  . Examples: (->), Int#. ;<A type or data family, with a list of its visible instances <A "plain" type constructor. "Fancier"& type constructors are returned using : or ; as appropriate =A class method >.A class, with a list of its visible instances M0Type constructors and classes; Haskell has them ! in the same name space for now. NData constructors O Variables Q)Global name bound outside of the TH AST: 2 An original name (occurrences only, not binders) * Need the namespace too to be sure which  thing we are naming R'Local name bound outside of the TH AST SA unique local name T$A qualified name; dynamically bound U'An unqualified name; dynamically bound hInput/output (dangerous) m,Report an error (True) or warning (False),  but carry on; use % to stop. n9Report an error to the user, but allow the current splice'9s computation to carry on. To abort the computation, use %. o,Report a warning to the user, and carry on. pRecover from errors raised by n or %. rDLook up the given name in the (type namespace of the) current splice' s scope. See %Language.Haskell.TH.Syntax#namelookup for more details. sELook up the given name in the (value namespace of the) current splice' s scope. See %Language.Haskell.TH.Syntax#namelookup for more details. tt looks up information about the . <It is sometimes useful to construct the argument name using r or s Xto ensure that we are reifying from the right namespace. For instance, in this context:   data D = D which D does reify (mkName "D")$ return information about? (Answer: D-the-type, but don't rely on it.) #To ensure we get information about D-the-value, use s:   do " Just nm <- lookupValueName "D"  reify nm and to get information about D-the-type, use r. ureifyInstances nm tys( returns a list of visible instances of nm tys . That is, if nmL is the name of a type class, then all instances of this class at the types tys  are returned. Alternatively, if nm. is the name of a data family or type family, *all instances of this family at the types tys are returned. v%Is the list of instances returned by u nonempty? w3The location at which this computation is spliced. xThe x function lets you run an I/O computation in the ~ monad. 8 Take care: you are guaranteed the ordering of calls to x within  a single ~B computation, but not about the order in which splices are run. DNote: for various murky reasons, stdout and stderr handles are not G necesarily flushed when the compiler finishes running, so you should  flush them yourself. y<Record external files that runIO is using (dependent upon). r The compiler can then recognize that it should re-compile the file using this TH when the external file changes. Y Note that ghc -M will still not know about these dependencies - it does not execute TH.  Expects an absolute file path. #The name without its module prefix &Module prefix of a name, if it exists Only used internally  Used for '+x etc, but not available to the programmer Tuple data constructor Tuple type constructor Unboxed tuple data constructor Unboxed tuple type constructor (Highest allowed operator precedence for 0 constructor (answer: 9) Default fixity: infixl 9 &YAlthough the NameFlavour type is abstract, the Data instance is not. The reason for this \ is that currently we use Data to serialize values in annotations, and in order for that to 4 work for Template Haskell names introduced via the '(x syntax we need gunfold on NameFlavour  to work. Bleh! ]The long term solution to this is to use the binary package for annotation serialization and d then remove this instance. However, to do _that_ we need to wait on binary to become stable, since ? boot libraries cannot be upgraded seperately from GHC itself. 9This instance cannot be derived automatically due to bug #2701 6 {|}~  (Eq a, Ord b)      !"#$%&'()*+,-./0123456789:;<=>?Line and character position @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a Fresh names b*Report an error (True) or warning (False)  ...but carry on; use % to stop cthe error handler action which may fail Recover from the monadic % defghijklmnophandler to invoke on failure computation to run qrstuvwxyz{|}~'()*+&,-./0123456789:;<= {|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~`abcdefghijk~^_lmnopqrstuvwxy]z{|}~[\YZWXVPUTSRQLONMK GJIH@ABCDEF?6>=<;:987543201,/.-"+*)('&%$#! |}{      {     |}~^_! V" +*)('&%$#,/.-0123456>=<;:987?@ABCDEFGJIHKLONMPUTSRQWXYZ[\]` abcdefghijklmnopqrstuvwxyz{|}~'()*+&,-./0123456789:;<= Safe-Infered" Use with 1 # Use with E +Dynamically binding a variable (unhygenic) Single-arg lambda  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvɨ   !ABCD>=?@"#$%&'()*+,-./012389:;<4567FEIGHJKLMNOPQRSTUVWX\]^_bcdighefjY[Z`aklnmopqsrtuv  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv Safe-Infered converts a value to a 'Q Exp' representation of the same ; value. It takes a function to handle type-specific cases.  converts a value to a 'Q Pat' representation of the same ; value. It takes a function to handle type-specific cases.  takes a ! and lifts it into one that read / the data out of a file. For example, suppose asmq is an C assembly-language quoter, so that you can write [asmq| ld r1, r2 |] & as an expression. Then if you define asmq_f = quoteFile asmq, then  the quote [asmq_f| foo.s |] will take input from file foo.s instead  of the inline text wxyz wxyz wxzywxzy Safe-Infered!Returns > if the document is empty An empty document A ';' character A ',' character A : character A space character A '=' character A -> string A '(' character A ')' character A '[' character A ']' character A '{' character A '}' character Wrap document in (...) Wrap document in [...] Wrap document in {...} Wrap document in '...' Wrap document in "..." Beside List version of  Beside, separated by space List version of  Above; if there is no  overlap it " dovetails" the two Above, without dovetailing. List version of  Either hcat or vcat Either hsep or vcat "Paragraph fill" version of cat "Paragraph fill" version of sep Nested  !hang d1 n d2 = sep [d1, nest n d2] punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn]0?@..0?@ Safe-Infered>      !"#$ABCDEFGHIJKLMNOPQRSTUVW'      !"#$'      !"#$<      !"#$ABCDEFGHIJKLMNOPQRSTUVW Safe-Inferedv  !"#$%&'()*+,-/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\]^_`abcdeghijmnopqruv{|}~      !"#$%&'()*+,-./0123456789:;<=>@ABCDEFLlmnoprstuvwx v~lnompw@ABCDEFxt6>=<;:9872543rsuvL}01,/.-{     |"+*)('&%$#!     !>=?@"#$%&'()*+,-/0189:;<456723ABCDbcdighejYZ`aVWX\]^_nmFEIGHJKLQRSTUuvopqrMNOP X      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./01234456789:;<=>?@ABCCDEFGHIJKLMNOPQRSTUVWXXYYZZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWtemplate-haskellLanguage.Haskell.TH.SyntaxLanguage.Haskell.TH.LibLanguage.Haskell.TH.QuoteLanguage.Haskell.TH.PprLibLanguage.Haskell.TH.PprdynLanguage.Haskell.THreturnQbindQ sequenceQliftnewNamemkName mkNameG_v mkNameG_d mkNameG_tcmkNameLcharLstringLintegerLintPrimL wordPrimL floatPrimL doublePrimL rationalL liftStringlitPvarPtupP unboxedTupPconPinfixPtildePbangPasPwildPrecPlistPsigPviewPfieldPatmatchclausevarEconElitEappEinfixEinfixAppsectionLsectionRlamEtupE unboxedTupEcondEletEcaseEdoEcompEfromE fromThenEfromToE fromThenToElistEsigErecConErecUpdEfieldExpguardedBnormalBnormalGEpatGEbindSletSnoBindSparSfunDvalDdataDnewtypeDtySynDclassD instanceDsigDforImpDpragInlD pragSpecD pragSpecInlD familyNoKindD familyKindD dataInstD newtypeInstD tySynInstDcxtclassPequalPisStrict notStrictunpackednormalCrecCinfixCforallC strictType varStrictTypeforallTvarTconTtupleT unboxedTupleTarrowTlistTappTsigTplainTVkindedTVstarKarrowKcCallstdCallunsafesafe interruptiblefunDeptypeFamdataFamquoteExpquotePatquoteDec quoteTypeExpMatchClauseQExpQDecQPatMatchQClauseQStmtQConQTypeQTypeDecVarStrictTypeQ StrictTypeQFieldExpFieldPatNamePatQ FieldPatQ FieldExpQFunDepPredPredQ TyVarBndrDecsQKindTyLitStrTyLitNumTyLitKindedTVPlainTVLitT ConstraintTStarT PromotedConsT PromotedNilTPromotedTupleTListTArrowT UnboxedTupleTTupleT PromotedTConTVarTSigTAppTForallT VarStrictType StrictTypeConForallCInfixCRecCNormalCStrictUnpacked NotStrictIsStrictEqualPClassPCxtRuleBndr TypedRuleVarRuleVarPhases BeforePhase FromPhase AllPhases RuleMatchFunLikeConLikeInline InlinableNoInlinePragmaRulePSpecialiseInstP SpecialisePInlinePSafety InterruptibleSafeUnsafeCallconvStdCallCCallForeignExportFImportF FamFlavourDataFamTypeFam TySynInstD NewtypeInstD DataInstDFamilyDPragmaDInfixDForeignDSigD InstanceDClassDTySynDNewtypeDDataDValDFunDRange FromThenToRFromToR FromThenRFromRStmtParSNoBindSLetSBindSGuardPatGNormalGBodyNormalBGuardedBRecUpdERecConESigEListE ArithSeqECompEDoECaseELetEMultiIfECondE UnboxedTupETupELamCaseELamEParensEUInfixEInfixEAppELitEConEVarEViewPSigPListPRecPWildPAsPBangPTildePParensPUInfixPInfixPConP UnboxedTupPTupPVarPLitPLit StringPrimL DoublePrimL FloatPrimL WordPrimLIntPrimL RationalLIntegerLStringLCharLFixityDirectionInfixNInfixRInfixLFixity InstanceDecUnliftedArity ParentNameInfoTyVarIVarIDataConI PrimTyConIFamilyITyConIClassOpIClassICharPosLoc loc_filename loc_package loc_module loc_startloc_endNameIsInfixAppliedAloneUniq NameSpace TcClsNameDataNameVarName NameFlavourNameGNameLNameUNameQNameSOccNamePkgNameModNameLiftunQQuasiqNewNameqReportqRecover qLookupNameqReifyqReifyInstances qLocationqRunIOqAddDependentFilebadIOcounterrunQreport reportError reportWarningrecover lookupNamelookupTypeNamelookupValueNamereifyreifyInstances isInstancelocationrunIOaddDependentFiletrueName falseName nothingNamejustNameleftName rightName mkModName modString mkPkgName pkgString mkOccName occString con_NameS con_NameQ con_NameU con_NameL con_NameGty_NameFlavournameBase nameModulemkNameUmkNameGshowName showName' tupleDataName tupleTypeName mk_tup_nameunboxedTupleDataNameunboxedTupleTypeNamemk_unboxed_tup_name maxPrecedence defaultFixitycmpEqthenCmp RuleBndrQRangeQGuardQBodyQCxtQTyLitQInfoQ stringPrimLuInfixPparensPfromR fromThenRfromToR fromThenToRnormalGpatGglobalparensEuInfixElam1ElamCaseEmultiIfE arithSeqEstringEinfixLDinfixRDinfixND pragSpecInstD pragRuleDlitT promotedTpromotedTupleT promotedNilT promotedConsTnumTyLitstrTyLitvarKconKtupleKlistKappK constraintKruleVar typedRuleVarappsE QuasiQuoterdataToQa dataToExpQ dataToPatQ quoteFileDocPprMpprNamepprName' to_HPJ_DocisEmptyemptysemicommacolonspaceequalsarrowlparenrparenlbrackrbracklbracerbracetextptextcharintintegerfloatdoublerationalparensbracketsbracesquotes doubleQuotes<>hcat<+>hsep$$$+$vcatcatsepfcatfsepnesthang punctuatePprpprppr_list Precedence nestDepthappPrecopPrecunopPrecnoPrecparensIfpprintppr_sig pprFixity pprInfixExppprExp pprFields pprMaybeExp pprGuardedpprBodypprLit bytesToString pprStringpprPatppr_decppr_data ppr_newtype ppr_tySynpprVarStrictType pprStrictType pprParendTypepprTyApp pprFunArgTypesplitpprTyLitpprCxt where_clause showtextl hashParens quoteParensbaseGHC.Basefail$fDataNameFlavour $fShowName$fOrdNameFlavour$fEqNameFlavour $fOrdName$fEqName$fLift(,,,,,,) $fLift(,,,,,) $fLift(,,,,) $fLift(,,,) $fLift(,,) $fLift(,)$fLift[] $fLiftEither $fLiftMaybe $fLiftBool $fLiftChar $fLiftInt $fLiftInteger$fQuasiQ$fApplicativeQ $fFunctorQ$fMonadQ $fQuasiIOghc-prim GHC.TypesTrue $fMonadPprM $fShowPprM $fPprRange $fPprPred$fPprTyVarBndr $fPprTyLit $fPprType$fPprCon $fPprClause $fPprRuleBndr $fPprPhases$fPprRuleMatch $fPprInline $fPprPragma $fPprForeign$fPprFamFlavour $fPprFunDep$fPprDec$fPprPat $fPprMatch $fPprStmt$fPprExp $fPprInfo $fPprName$fPpr[]