úÎ!ºö¸#      !"None&'-=?@ACHIMSX·B th-compat a is a type alias for: # a , if using template-haskell-2.17.0.0 or later, or# ($ a), if using an older version of template-haskell.[This should be used with caution, as its definition differs depending on which version of template-haskellÌ you are using. It is mostly useful for contexts in which one is writing a definition that is intended to be used directly in a typed Template Haskell splice, as the types of TH splices differ between template-haskell versions as well.Levity-polymorphic since template-haskell-2.16.0.0. th-compat m a is a type alias for: m a , if using template-haskell-2.17.0.0 or later, orm ($ a), if using an older version of template-haskell.[This should be used with caution, as its definition differs depending on which version of template-haskellÌ you are using. It is mostly useful for contexts in which one is writing a definition that is intended to be used directly in a typed Template Haskell splice, as the types of TH splices differ between template-haskell4 versions as well. One example of a type that uses  is the type signature for lifTypedFromUntypedSplice.Levity-polymorphic since template-haskell-2.16.0.0. th-compatLevity-polymorphic since template-haskell-2.16.0.0. th-compatUnderlying monadic value th-compat@A class that allows one to smooth over the differences between  m a4 (the type of typed Template Haskell quotations on template-haskell-2.17.0.0 or later) and m (TExp a)F (the type of typed Template Haskell quotations on older versions of template-haskellE). Here are two examples that demonstrate how to use each method of : ){-# LANGUAGE TemplateHaskell #-} import Language.Haskell.TH import !Language.Haskell.TH.Syntax.Compat -- & will ensure that the end result is a 6, regardless of -- whether the quote itself returns a  or a TExp . myCode ::  # Int myCode =  [|| 42 ||] --  will ensure that the input 2 is suitable for splicing (i.e., it will return a  or a TExp depending on the template-haskell2 version in use). fortyTwo :: Int fortyTwo = $$( myCode) Levity-polymorphic since template-haskell-2.16.0.0. th-compatConvert something to a . th-compatConvert to something from a .% th-compat#An internal definition that powers . Its & instance defines ' in terms of   from  %, but defines every other method of &9 to be an error, since they cannot be implemented using   alone. Similarly, its  MonadFail and ( instances define ) and *, respectively, to be errors.  th-compatThe  V class implements the minimal interface which is necessary for desugaring quotations.The Monad mF superclass is needed to stitch together the different AST fragments. U is used when desugaring binding structures such as lambdas to generate fresh names.GTherefore the type of an untyped quotation in GHC is `Quote m => m Exp`†For many years the type of a quotation was fixed to be `Q Exp` but by more precisely specifying the minimal interface it enables the +E to be extracted purely from the quotation without interacting with #.  th-compat0Generate a fresh name, which cannot be captured.For example, this: .f = $(do nm1 <- newName "x" let nm2 = mkName "x" return (LamE [VarP nm1] (LamE [VarP nm2] (VarE nm1))) )will produce the splice f = \x0 -> \x -> x0In 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: og = $(do nm1 <- newName "x" let nm2 = mkName "x" return (LamE [VarP nm2] (LamE [VarP nm1] (VarE nm2))) )will produce the splice g = \x -> \x0 -> x0since the occurrence VarE nm2+ is captured by the innermost binding of x , namely VarP nm1.  th-compatLDiscard the type annotation and produce a plain Template Haskell expressionLevity-polymorphic since template-haskell-2.16.0.0.This is a variant of the unTypeQ. function that is always guaranteed to use a  % constraint, even on old versions of template-haskell.ZAs this function interacts with typed Template Haskell, this function is only defined on template-haskell-2.9.0.0 (GHC 7.8) or later.  th-compat4Annotate the Template Haskell expression with a typepThis is unsafe because GHC cannot check for you that the expression really does have the type you claim it has.Levity-polymorphic since template-haskell-2.16.0.0.This is a variant of the unsafeTExpCoerce. function that is always guaranteed to use a  & constraint, even on old versions of template-haskell.ZAs this function interacts with typed Template Haskell, this function is only defined on template-haskell-2.9.0.0 (GHC 7.8) or later.  th-compatOTurn a value into a Template Haskell expression, suitable for use in a splice.This is a variant of the , method of -% that is always guaranteed to use a  & constraint, even on old versions of template-haskell.Levity-polymorphic since template-haskell-2.17.0.0. th-compat[Turn a value into a Template Haskell typed expression, suitable for use in a typed splice.This is a variant of the  method of -% that is always guaranteed to use a   constraint and return a , even on old versions of template-haskell.ZAs this function interacts with typed Template Haskell, this function is only defined on template-haskell-2.9.0.0 (GHC 7.8) or later. While the  method of - was first introduced in template-haskell-2.16.0.0&, we are able to backport it back to template-haskell-2.9.0.0 by making use of the , method on older versions of template-haskell . This crucially relies on the - law that lift x "a unTypeQ ( liftTyped x) to work, so beware if you use  with an unlawful - instance.Levity-polymorphic since template-haskell-2.17.0.0. th-compatThis is a variant of the .. function that is always guaranteed to use a  & constraint, even on old versions of template-haskell. th-compatUse a # computation in a  / context. This function is only safe when the #' computation performs actions from the   instance for # or any of  's subclasses (/, 0, and 1+). Attempting to perform actions from the  MonadFail, (, or & instances for # will result in runtime errors."This is useful when you have some #3-valued functions that only performs actions from   and wish to generalise it from # to  ƒ without having to rewrite the internals of the function. This is especially handy for code defined in terms of combinators from Language.Haskell.TH.Lib , which were all hard-coded to # prior to template-haskell-2.17.0.0(. For instance, consider this function:  apply :: + -> + -> # + apply f x =  (return x) (return y) 6There are two ways to generalize this function to use  @ in a backwards-compatible way. One way to do so is to rewrite apply to avoid the use of  , like so: applyQuote ::   m => + -> + -> m + applyQuote f x = return (2 x y) For a small example like  applyQuotee, there isn't much work involved. But this can become tiresome for larger examples. In such cases, 0 can do the heavy lifting for you. For example,  applyQuote can also be defined as: applyQuote ::   m => + -> + -> m + applyQuote f x =  (apply f x)  th-compatRUnsafely convert an untyped code representation into a typed code representation.Levity-polymorphic since template-haskell-2.16.0.0. th-compat4Lift a monadic action producing code into the typed  representationLevity-polymorphic since template-haskell-2.16.0.0. th-compat@Extract the untyped representation from the typed representationLevity-polymorphic since template-haskell-2.16.0.0. th-compatPModify the ambient monad used during code generation. For example, you can use  to handle a state effect: a handleState :: Code (StateT Int Q) a -> Code Q a handleState = hoistCode (flip runState 0) Levity-polymorphic since template-haskell-2.16.0.0. th-compatZVariant of (>>=) which allows effectful computations to be injected into code generation.Levity-polymorphic since template-haskell-2.16.0.0. th-compatYVariant of (>>) which allows effectful computations to be injected into code generation.Levity-polymorphic since template-haskell-2.16.0.0. th-compat7A useful combinator for embedding monadic actions into  g myCode :: ... => Code m a myCode = joinCode $ do x <- someSideEffect return (makeCodeWith x) Levity-polymorphic since template-haskell-2.16.0.0. th-compat A variant of  that is: Always implemented in terms of , behind the scenes, and Returns a g. This means that the return type of this function will be different depending on which version of template-haskell* you are using. (See the Haddocks for ) for more information on this point.)VThis is primarily useful for minimizing CPP in one particular scenario: implementing  in hand-written -$ instances where the corresponding ,Q implementation cannot be derived. For instance, consider this example from the text library:  instance - Text where , = appE (varE 'pack) . stringE . unpack #if ( (2) < 2 || (2) == 2 && (17) < 14 || (2) == 2 && (17) == 14 && (0) <= 0)  =  . ,Z #elif ( (2) < 2 || (2) == 2 && (16) < 14 || (2) == 2 && (16) == 14 && (0) <= 0)  = 3 . , #endif  The precise details of how this ,I implementation works are not important, only that it is something that  DeriveLift could not generate. The main point of this example is to illustrate how tiresome it is to write the CPP necessary to define 2 in a way that works across multiple versions of template-haskell. With 3, however, this becomes slightly easier to manage:  instance - Text where , = appE (varE 'pack) . stringE . unpack #if ( (2) < 2 || (2) == 2 && (16) < 14 || (2) == 2 && (16) == 14 && (0) <= 0)  =  #endif LNote that due to the way this function is defined, this will only work for - instances t such that  (t :: Type)". If you wish to manually define 9 for a type with a different kind, you will have to use / to overcome levity polymorphism restrictions. th-compatYUnsafely convert an untyped code representation into a typed code representation, where:The splice representation is  m a, if using template-haskell-2.17.0.0 or later, orThe splice representation is m ($ a)", if using an older version of template-haskell.WThis is primarily useful for minimizing CPP when the following two conditions are met: You need to implement  in a hand-written -& instance where the corresponding ,* implementation cannot be derived, andThe data type receiving a Lift instance has a kind besides Type.JCondition (2) is important because while it is possible to simply define 'Syntax.liftTyped =  for - instances t such that  (t :: Type)•, this will not work for types with different types, such as unboxed types or unlifted newtypes. This is because GHC restrictions prevent defining 3 in a levity polymorphic fashion, so one must use F to work around these restrictions. Here is an example of how to use :  instance - Int# where ,‚ x = litE (intPrimL (fromIntegral (I# x))) #if ( (2) < 2 || (2) == 2 && (16) < 14 || (2) == 2 && (16) == 14 && (0) <= 0)  x =  (, x) #endif Levity-polymorphic since template-haskell-2.16.0.0. th-compatLevity-polymorphic since template-haskell-2.16.0.0. th-compatLevity-polymorphic since template-haskell-2.16.0.0.   4       !"#$%&'()*()+,()-()./01/23/04()5()6()7()8/29/2:/2;()<()=>$th-compat-0.1-EpxuNeqz3Pd7gZYURLUWTC!Language.Haskell.TH.Syntax.CompatSyntax liftTypedLibappESpliceQSpliceCodeQCode examineCodeIsCodetoCodefromCodeQuotenewName unTypeQQuoteunsafeTExpCoerceQuote liftQuoteliftTypedQuoteliftStringQuoteunsafeQToQuoteunsafeCodeCoerceliftCode unTypeCode hoistCodebindCode bindCode_joinCodeliftTypedFromUntypedSpliceunsafeSpliceCoerce$fQuoteQ$fQuasiQuoteToQuasi$fMonadIOQuoteToQuasi$fMonadFailQuoteToQuasi $fIsCodeQaQ$fIsCodeqaCode$fFunctorQuoteToQuasi$fApplicativeQuoteToQuasi$fMonadQuoteToQuasitemplate-haskellLanguage.Haskell.TH.SyntaxQTExp QuoteToQuasiQuasiqNewNamebaseControl.Monad.IO.ClassMonadIOGHC.BasefailliftIOExpliftLift liftStringFunctor ApplicativeMonadAppEunsafeTExpCoerce