úÎ>Ã:Å0      !"#$%&'()*+,-./None0MDebugging Template Haskell stuff at the GHCi REPL is hard because everything ends up in the Q( monad and there is no way to print the Q monad. These functions "call pprint and show but return a Q Exp( so that the following expressions work to print a given value (e.g. x):  $(pprintQ x)  $(showQ x) NNOTE: GHCi likes to run the contents of splices twice or more, so the results may be printed multiple times. 010101 Safe-Infered222 Safe-Infered345678345678None0CPrimitive case expression generation. Most users will want to use   instead. >Case expression generation. This is the core function of the $ Template Your Boilerplate library. This function is similar to thcase', except that since most users B will note care about the distinction between types and primitive I types, this function smooths over the differences by treating primitive + types as types with nullary constructors. >Scrap Your Boilerplate style case expression generation. The  : function is generally simpler to use instead of this and  is more powerful. $Generic single-layer transformation Generic single-layer query. 0Generic single-layer query (right associative). /Generic single-layer query (left associative). -Generic single-layer monadic transformation. BMemoizes a code generation function. Most users will want to use  8 instead as it provides a simplified interface, but all ,the notes about this function also apply to  . #We memoize a function returning an 9 by creating a : with a body that is the 9. returned by that function. The return value #of the function is replaced with a ; that refers to the :. This allows functions like   to avoid infinite :recursions when they traverse recursive types like lists. /The memoization functions come in two flavors:  and  . With ! it is the responsibility of the caller to place the : in an appropriate place. The  $ function automatically handles the : by wrapping them in a local < form. @Every memoized function is passed a memoized version of itself. =This is the function that should be used in recursive calls. ?Failing to do so will prevent those calls from being memoized. 0Mutually recursive functions are possible using  ,  etc. and  , etc. CIf the function being memoized needs to accept multiple arguments, Gthen they must be packed into a tuple and passed as a single argument. Effects in the m- monad are only performed the first time the Dmemoized function is called with a particular argument. Subsequent *times the monad is simply the result of a =. Thus while it Cis tempting to store extra return values in the monad, this should >be avoided due to the high likelihood of unexpected behavior. Implementation Notes:  Note that m4 should not store a copy of the function, otherwise ) a memory leak is introduced. It wouldn't even make sense to do B it anyway since the results refer to expressions that might not  be in scope. = The memoized function stores a reference to the memoization B table, Thus if a reference to the memoized function gets tucked  inside m2, then a memory leak can be introduced. We could B eliminate this leak by clearing and invalidating the table when  5 returns. To fully do this properly the table would D have to be invalidated in such a way that the memoized version of A the function would not continue to try populating the table if  the user called it after  return. B Conceptually we should use a State monad instead of an IORef but > we choose IORef since we can embed IO operations in a Quasi ) without imposing extra restrictions on m. > Other designs are possible. This design was choosen for its = simplicity of use. The choice of memoization interface is 2 largely orthogonal to the rest of this library. C Type synonyms and kind annotations may lead to duplicate versions & of the code (e.g. versions for both > and [?])  Usually this isn')t a problem, but if it is, then the type ? synonyms should be expanded before each call to the memoized  function.  GADTs and data/type families haven't been considered in this * code. It is unknown whether they work. 0Note that polymorphically recursive types (e.g. data F a = N a | F (F  (Int, a))<) have an infinite number of types in them and thus despite =memoization this function will not terminate on those types. ?Simultaneously memoizes two code generation functions. All of  the notes about $ also apply to this function. Most  users will want to use   instead of this function as it " provides a simplified interface. =Memoizes a code generation function. Behaves identically to   except that it returns a < that binds the :  resulting from  for the 9 resulting from  . @Simultaneously memoizes two code generation functions. Behaves  identically to   except that it returns a < that  binds the : resulting from   for the 9  resulting from  . -Generic recursive transformation (bottom-up) ,Generic recursive transformation (top-down) GGeneric recursive transformation (bottom-up) with selective traversal. , Skips traversal when a given query returns @. 5Generic recursive monadic transformation (bottom-up) 4Generic recursive monadic transformation (top-down) NGeneric recursive monadic transformation (top-down) with selective traversal. , Skips traversal when a given query returns @. <Generic recursive transformation (bottom-up) with selective D traversal. Recurs on only types that can contain a type with type  specific behavior. :Generic recursive monadic transformation (bottom-up) with D selective traversal. Recurs on only types that can contain a type  with type specific behavior. GGeneric recursive transformation (bottom-up) with selective traversal. OGeneric recursive monadic transformation (bottom-up) with selective traversal. %Generic recursive query (bottom-up). <Generic recursive query with left-associative accumulation. BGeneric recursive query with strict left-associative accumulation SGeneric recursive query with left-associative accumulation and selective traversal ZGeneric recursive query with strict left-associative accumulation and selective traversal <Generic recursive query with right-associative accumulation TGeneric recursive query with right-associative accumulation and selective traversal 1Generic recursive query with selective traversal @Generic recursive traversal using left-associative accumulation GGeneric recursive traversal using strict left-associative accumulation AGeneric recursive traversal using right-associative accumulation !<Returns the type of a variable, method or constructor name. "]Extends a generic operation with type specific behavior based on the type of the given name. #9Extends a generic operation with type specific behavior. $9Extends a generic operation with type specific behavior. %.Makes a transformation from a named function. &5Makes a transformation from several named functions. '6Makes a monadic transformation from a named function. (=Makes a monadic transformation from several named functions. )%Makes a query from a named function. *,Makes a query from several named functions. +;Tests if two types are equal modulo type synonyms and kind 3 annotations. Naive equality would fail to equate String and  [Char]. ,=Test if any of a list of types is equal to a particular type B modulo type synonyms and kind annotations. Useful when multiple . types share the same type-specific behavior. -containsType t1 t2 = True iff t1 is (even recursively) inside t2 .containsTypes ts t2 = True iff any of ts is (even recursively) inside t2 /*Returns the constructors of a given type.  Returns Nothing if the type is primitive. 0 Case handling function. If the A being inspected is  a primitive type, argument is B var where var is a 6 variable bound to the case discriminant. Otherwise,  argument is C (ctor, args) where ctor is the  constructor name and args is a list of the argument's / types and the variable bound to the argument. The type to inspect. The expression containing the case ( expression. If the type to inspect is t and  the type of the 9 returned by the case  handling function is r, the 9 returned by  thcase' is of type t -> r. @Case handling function. The first argument is the constructor. ? The second argument is the list of arguments and their types. The type to inspect. The expression containing the case expression. If  the type to inspect is t and the type of the 9 + returned by the case handling function is r, the  9 returned by thcase is of type t -> r. 0Constructor argument application. If the first 9 is of  type  c (a -> b), the A is a, and the second 9 is of  type a, should return an 9 of type c b. %Constructor injection. The argument 9 / will be one of the constructors from the type # to be inspected. If the argument 9 is of  type a, should return an 9 of type c  a. The type to inspect. The expression containing the case expression. If  the type to inspect is t and the type of the 9 + returned by the case handling function is c t, the  9 returned by thcase is of type t -> c t. The transformation. If the A is t, must  return an 9 of type t -> t.  Generates an 9 that applies the - transformation to each immediate child. If  A is t0 , returns an 9 of type t0  -> t0. )The query. Extracts data from the given  type. If the A is t, must return an 9  of type t -> a.  Generates an 9 that applies the query " to each immediate child. If the A is t0,  returns an 9 of type t0 -> [a]. Combining function. 9 must have type r' -> r -> r Starting value. 9 must have type r. (The query. Extract data from the given  type. If the A is t, must return an 9  of type t -> r'.  Generates an 9 that applies the query & to each immediate child and uses the + starting value and combining functions to ! fold the query results. If the A is t0,  returns an 9 of type t0 -> r. Combining function. 9 must have type r -> r' -> r Starting value. 9 must have type r. (The query. Extract data from the given  type. If the A is t, must return an 9  of type t -> r'.  Generates an 9 that applies the query & to each immediate child and uses the + starting value and combining functions to ! fold the query results. If the A is t0,  returns an 9 of type t0 -> r. $The monadic transformation. If the A is  t, must return an 9 of type t -> m t  Generates an 9 that applies the * monadic transformation to each immediate  child. If the A is t0 , returns an 9  of type  t0 -> m t0.  The function to memoize. Takes  a memoized version of the  function as argument. &The initial argument to the function. The result of applying the # function to the initial argument.  The |Exp| is the result, but  expects the [:] to be in  scope. ?The first function to memoize. Takes memoized versions of the  two functions as arguments. @The second function to memoize. Takes memoized versions of the  two functions as arguments. The initial argument. +The result of applying the function to the 1 initial argument. The |Exp| is the result, but  expects the [:] to be in scope. The transformation. If the A is t, must  return an 9 of type t -> t.  Generates an 9 that applies the ( transformation to each descendant. If  A is t0 , returns an 9 of type t0  -> t0. The transformation. If the A is t, must  return an 9 of type t -> t.  Generates an 9 that applies the ( transformation to each descendant. If  A is t0 , returns an 9 of type t0  -> t0. The query. Should return @ when a % given type should not be traversed. The transformation. If the A is t,  must return an 9 of type t -> t.  Generates an 9 that applies the + transformation to each descendant (except . for parts skipped due to the query returning  @ ). If the A is t0 , returns an  9 of type t0 -> t0. $The monadic transformation. If the A is t, must  return an 9 of type t -> m t.  Generates an 9 that applies the ( transformation to each descendant. If  A is t0 , returns an 9 of type t0  -> m t0. $The monadic transformation. If the A is t, must  return an 9 of type t -> m t.  Generates an 9 that applies the ( transformation to each descendant. If  A is t0 , returns an 9 of type t0  -> m t0. The query. Should return @ when a % given type should not be traversed. $The monadic transformation. If the A is t,  must return an 9 of type t -> m t.  Generates an 9 that applies the 3 monadic transformation to each descendant (except . for parts skipped due to the query returning  @ ). If the A is t0 , returns an  9 of type  t0 -> m t0. Name of a function of type t -> t  Generates an 9 that applies the . transformation to each descendant that is of  type t . If the A is t0 , returns an  9 of type t0 -> t0. Name of a function of type t -> m t  Generates an 9 that applies the + monadic transformation to each descendant  that is of type t . If the A is t0,  returns an 9 of type  t0 -> m t0. 8The transformation. The first argument is the memoized  recursion. If D! is returned, then the standard, " automatic recursion is done. If E is returned, then no / automatic recursion is done and the resulting 9 is used at A that type. In that case, if further recursion is desired, then A the expression should include a call to the memoized recursion.  If the A is t, then the returned 9 must be of type t  -> t. We use F instead of G to avoid the user having to  play games with  runMaybeT and so forth.  Generates an 9) that applies the transformation to each  descendant. If A is t0 , returns an 9 of type t0 ->  t0. @The monadic transformation. The first argument is the memoized  recursion. If D! is returned, then the standard, " automatic recursion is done. If E is returned, then no / automatic recursion is done and the resulting 9 is used at A that type. In that case, if further recursion is desired, then A the expression should include a call to the memoized recursion.  If the A is t, then the returned 9 must be of type t  -> m t. We use F instead of G to avoid the user having to  play games with  runMaybeT and so forth.  Generates an 9) that applies the transformation to each  descendant. If A is t0 , returns an 9 of type t0 ->  m t0. Combining function. 9 must have type  r -> r -> r. (The query. Extract data from the given  type. If the A is t, must return an 9  of type t -> r'.  Generates an 9 that applies the query + to each descendant and uses the combining , function to combine the query results. If  the A is t0 , returns an 9 of type  t0 -> r. *The query and combining function. If the  A is t, must return an 9 of type t  -> r -> r.  Generates an 9 that applies the query  to each decendant. If A is t0,  returns an 9 of type  t0 -> r -> r *The query and combining function. If the  A is t, must return an 9 of type t  -> r -> r.  Generates an 9 that applies the query  to each decendant. If A is t0,  returns an 9 of type  t0 -> r -> r 4The query, combining, selectivity function. If the A is  t, must return an 9 of type  t -> r -> r . If the H  is @1 the traversal does not proceed further into the  recursion.  Generates an 9 that applies the query  to each decendant. If A is t0,  returns an 9 of type  t0 -> r -> r 4The query, combining, selectivity function. If the A is  t, must return an 9 of type  t -> r -> r . If the H  is @1 the traversal does not proceed further into the  recursion.  Generates an 9 that applies the query  to each decendant. If A is t0,  returns an 9 of type  t0 -> r -> r *The query and combining function. If the  A is t, must return an 9 of type t  -> r -> r.  Generates an 9 that applies the query  to each decendant. If A is t0,  returns an 9 of type  t0 -> r -> r 4The query, combining, selectivity function. If the A is  t, must return an 9 of type  t -> r -> r . If the H  is @1 the traversal does not proceed further into the  recursion.  Generates an 9 that applies the query  to each decendant. If A is t0,  returns an 9 of type  t0 -> r -> r Combining function. 9 must have type  r -> r -> r. 4The query, combining, selectivity function. If the A is  t, must return an 9 of type  t -> r -> r . If the H  is @1 the traversal does not proceed further into the  recursion.  Generates an 9 that applies the query  to each decendant. If A is t0,  returns an 9 of type t0 -> r Name of a function of type  t -> r -> r  Generates an 9 that applies the query # to each decendant that is of type t. If  A is t0 , returns an 9 of type t0  -> r -> r Name of a function of type  t -> r -> r  Generates an 9 that applies the query # to each decendant that is of type t. If  A is t0 , returns an 9 of type t0  -> r -> r Name of a function of type  t -> r -> r  Generates an 9 that applies the query # to each decendant that is of type t. If  A is t0 , returns an 9 of type t0  -> r -> r !"The operation to be extended. >Name of the function implementing the type specific behavior. /The result of extending the operation. If the I has type  t -> s9, then the extended operation has type specific behavior  at t8. At other types it behaves as the original operation. #The operation to be extended. The J of the pair should return @ on types for which ( the operation should be extended. The K of the pair is the # expression to use on those types. 'The result of extending the operation. $The operation to be extended. The J of the pair should return @ on types for which ( the operation should be extended. The K% of the pair when given one of these As 3 should return the expression to use on that type. 'The result of extending the operation. %Name of a function of type t -> t $The generic transformation. If the A  is t0 , then the 9 has type t0 -> t0.  The 9 is the named function at t, and  L elsewhere. &Names of functions of type t -> t for various t. $The generic transformation. If the A  is t0 , then the 9 has type t0 -> t0. ' If one of the named functions matches t0,  then 9% is that function. Otherwise, it is  L. 'Name of a function of type t -> m t ,The generic monadic transformation. If the A  is t0 , then the 9 has type  t0 -> m t0.  The 9 is the named function at t, and  = elsewhere. (Names of functions of type t -> m t for various t. ,The generic monadic transformation. If the A  is t0 , then the 9 has type  t0 -> m t0. ' If one of the named functions matches t0,  then 9% is that function. Otherwise, it is  =. ),Default value to return on types other than t.  The 9 must be of type r. Name of a function of type t -> r $The generic transformation. If the A  is t0 , then the 9 has type t0 -> r.  The 9 is the named function at t, and ' the provided default value elsewhere. *-Default value to return on types that do not  match the t from any named function. The  9 must be of type r. Names of functions of type t -> r for various t. The generic query. If the A  is t0 , then the 9 has type t0 -> r. ' If one of the named functions matches t0,  then 9% is that function. Otherwise, it is  M of the provided default value. +,-./0  !"#$%&'()*+,-./0  "#$%&)*'(+,-./!0  !"#$%&'()*+,-./N      !"#$%&'()*+,-./0123456789:;<=>?@>?A>?B>?CDEFDEGHIJHIK>?LDMNDMODPQDPRDPSDTUHIV>?WDXYDXZDE[DE\] TYB-0.2.0Data.Generics.THDebug.THData.Generics.TH.VarSetData.Generics.TH.Instancesthcase'thcasethfoldlthmapTthmapQthmapQrthmapQlthmapM memoizeDec memoizeDec2 memoizeExp memoizeExp2 everywhere everywhere' everywhereBut everywhereM everywhereM'everywhereButM' everywhereForeverywhereForM somewhere somewhereM everythingeverythingAccLeverythingAccL'everythingButAccLeverythingButAccL'everythingAccReverythingButAccR everythingButeverythingForLeverythingForL'everythingForR typeOfNameextNextEextE'mkTmkTsmkMmkMsmkQmkQseqTypeeqTypes containsType containsTypesconstructorsOfpprintQshowQvarSet $fQuasiMaybeT$fQuasiWriterT $fQuasiStateT$fQuasiReaderT $fQuasiListT $fQuasiErrorTtemplate-haskellLanguage.Haskell.TH.SyntaxExpDecVarELetEbaseGHC.BasereturnStringghc-prim GHC.TypesCharTrueType Data.EitherLeftRight Data.MaybeNothingJustMaybe Control.Monad MonadPlusBoolName Data.Tuplefstsndidconst