Îõ³h*9f8,      !"#$%&'()*+0.1.6 Trustworthy)*0ÂÄÅÆÈÍÎÒØÚÛÝ7µ 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-haskell versions as well.Levity-polymorphic since template-haskell-2.16.0.0. 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)Æ (the type of typed Template Haskell quotations on older versions of template-haskellÅ). 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 5 is suitable for splicing -- (i.e., it will return a  or a TExp depending on the -- template-haskell0 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 0 in terms of  from %, but defines every other method of /9 to be an error, since they cannot be implemented using  alone. Similarly, its 1 and 2 instances define 3 and 4, respectively, to be errors. th-compatÌDiscard the type annotation and produce a plain Template Haskell expressionLevity-polymorphic since template-haskell-2.16.0.0.This is a variant of the 5. function that is always guaranteed to use a % constraint, even on old versions of template-haskell.ÚAs 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 typeðThis 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 6. function that is always guaranteed to use a & constraint, even on old versions of template-haskell.ÚAs 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-compatÏTurn a value into a Template Haskell expression, suitable for use in a splice.This is a variant of the 7 method of 8% 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 9 method of 8% that is always guaranteed to use a  constraint and return a , even on old versions of template-haskell.ÚAs 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 9 method of 8 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 7 method on older versions of template-haskell . This crucially relies on the 8 law that lift x áD 5 ( liftTyped x) to work, so beware if you use  with an unlawful 8 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 (;, <, and =+). Attempting to perform actions from the 1, 2, 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 (? x y) For a small example like  applyQuoteå, 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-compat A variant of   that works over s. Because this function uses Í, the 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.)Levity-polymorphic since template-haskell-2.16.0.0. th-compat A variant of   that works over s. Because this function uses Í, the 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.)Levity-polymorphic since template-haskell-2.16.0.0. th-compatLift a - a into a Ø. This is useful when splicing in the result of a computation into a typed QuasiQuoter.One example is @Ëing over a list of elements and returning an expression from each element.  mkInt :: A -> , (- B/) mkInt str = [|| length $$str ||] mkInts :: [A] -> , [- B] mkInts = traverse mkInt This gives us a list of -, not a -Å of a list. We can push the list inside the type with this function:  listTE :: [- a] -> - [a] listTE = - . C . D E In a do block using  , we can bind the resulting- [B] out of the expression. foo :: , (-ð Int) foo = do ints <- mkInts ["hello", "world", "goodybe", "bob"] [|| sum $$(pure (listTE ints)) ||] Prior to GHC 9, with the , type, we can write F :: - a -> , (- a)€, which is a valid thing to use in a typed quasiquoter. However, after GHC 9, this code will fail to type check. There is no < instance for  m a*, so we need another way to splice it in.A GHC 9 only solution can use  :: m (- a) -> Code m a and F together, like:  . F.With ö, we can splice it in a backwards compatible way. A fully backwards- and forwards-compatible example looks like this:  mkInt :: A -> , B mkInt str = " [|| length $$str ||] mkInts :: [A] -> , [- B"] mkInts = traverse mkInt foo ::  B foo =  Ä $ do ints <- mkInts ["hello", "world", "goodybe", "bob"] + [|| sum $$(expToSplice (listTE ints)) ||]  th-compat A variant of  that takes a 0 as an argument. Because this function takes a Ü as an argyment, the 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.)Levity-polymorphic since template-haskell-2.16.0.0. th-compat A variant of  that works over s. Because this function uses Í, the 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.)Levity-polymorphic since template-haskell-2.16.0.0. th-compat A variant of   that works over s. Because this function uses Í, the 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.)Levity-polymorphic since template-haskell-2.16.0.0.  th-compat A variant of  that returns a #. Because this function returns a Ô, 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.)Levity-polymorphic since template-haskell-2.16.0.0.! th-compat A variant of  that is: Always implemented in terms of 7 behind the scenes, and Returns a ç. 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.)×This is especially useful for minimizing CPP in one particular scenario: implementing 9 in hand-written 8$ instances where the corresponding 7Ñ implementation cannot be derived. For instance, consider this example from the text library:  instance 8 Text where 7Ó = appE (varE 'pack) . stringE . unpack #if MIN_VERSION_template_haskell(2,17,0) 9 =  . 7. #elif MIN_VERSION_template_haskell(2,16,0) 9 = 6 . 7 #endif  The precise details of how this 7É 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 92 in a way that works across multiple versions of template-haskell. With !3, however, this becomes slightly easier to manage:  instance 8 Text where 7Ó = appE (varE 'pack) . stringE . unpack #if MIN_VERSION_template_haskell(2,16,0) 9 = ! #endif ÌNote that due to the way this function is defined, this will only work for 8 instances t such that  (t :: Type)". If you wish to manually define 99 for a type with a different kind, you will have to use "/ to overcome levity polymorphism restrictions." th-compat?Unsafely convert an untyped splice representation into a typed 2 representation. Because this function returns a Õ, 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.)2This is especially useful for minimizing CPP when: You need to implement 9 in a hand-written 8& instance where the corresponding 7* implementation cannot be derived, andThe data type receiving a Lift instance has a kind besides Type.ÊCondition (2) is important because while it is possible to simply define 'Syntax.liftTyped = ! for 8 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 "Æ to work around these restrictions. Here is an example of how to use ":  instance 8 Int# where 7Ö x = litE (intPrimL (fromIntegral (I# x))) #if MIN_VERSION_template_haskell(2,16,0) 9 x = " (7 x) #endif Levity-polymorphic since template-haskell-2.16.0.0.# th-compat A variant of  that takes a 0 as an argument. Because this function takes a Ü as an argyment, the 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.)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.$  !"# $  !"# Ç       !"#$%&'()*+,-./0123456789:8;<89=8;>?@ABCD8EF8EG8EHIJ8KL8EMNOPQ8ERS8ETÕ&th-compat-0.1.6-5ooPsWOcwMS9HDBQODA6Re!Language.Haskell.TH.Syntax.Compat th-compatLibappEtemplate-haskellLanguage.Haskell.TH.SyntaxnewName unTypeCodeunsafeCodeCoerceQuoteCode examineCodeliftCode hoistCodebindCode bindCode_joinCodegetPackageRootmakeRelativeToProject Language.Haskell.TH.Lib.InternalCodeQSpliceQSpliceIsCodetoCodefromCode unTypeQQuoteunsafeTExpCoerceQuote liftQuoteliftTypedQuoteliftStringQuoteunsafeQToQuote bindSplice bindSplice_ expToSplice examineSplice hoistSplice joinSplice liftSpliceliftTypedFromUntypedSpliceunsafeSpliceCoerce unTypeSplice$fQuasiQuoteToQuasi$fMonadIOQuoteToQuasi$fMonadFailQuoteToQuasi $fIsCoderQaQ$fIsCoderqaCode$fFunctorQuoteToQuasi$fApplicativeQuoteToQuasi$fMonadQuoteToQuasiQTExp QuoteToQuasiQuasiqNewNamebaseControl.Monad.Fail MonadFailControl.Monad.IO.ClassMonadIOfailliftIOunTypeQunsafeTExpCoerceliftLift liftTyped liftStringGHC.BaseFunctor ApplicativeMonadExpAppEData.TraversabletraverseStringghc-prim GHC.TypesIntListEmapunTypepure