-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | The 'Lift' typeclass.
--   
--   The stable home of TemplateHaskell's <a>Lift</a> typeclass, which
--   implements cross-stage persistence for Template Haskell.
@package template-haskell-lift
@version 0.1.0.0

module Language.Haskell.TH.Lift

-- | A <a>Lift</a> instance can have any of its values turned into a
--   Template Haskell expression. This is needed when a value used within a
--   Template Haskell quotation is bound outside the Oxford brackets
--   (<tt>[| ... |]</tt> or <tt>[|| ... ||]</tt>) but not at the top level.
--   As an example:
--   
--   <pre>
--   add1 :: Int -&gt; Q (TExp Int)
--   add1 x = [|| x + 1 ||]
--   </pre>
--   
--   Template Haskell has no way of knowing what value <tt>x</tt> will take
--   on at splice-time, so it requires the type of <tt>x</tt> to be an
--   instance of <a>Lift</a>.
--   
--   A <a>Lift</a> instance must satisfy <tt>$(lift x) ≡ x</tt> and
--   <tt>$$(liftTyped x) ≡ x</tt> for all <tt>x</tt>, where <tt>$(...)</tt>
--   and <tt>$$(...)</tt> are Template Haskell splices. It is additionally
--   expected that <tt><a>lift</a> x ≡ <a>unTypeQ</a> (<a>liftTyped</a>
--   x)</tt>.
--   
--   <a>Lift</a> instances can be derived automatically by use of the
--   <tt>-XDeriveLift</tt> GHC language extension:
--   
--   <pre>
--   {-# LANGUAGE DeriveLift #-}
--   module Foo where
--   
--   import Language.Haskell.TH.Syntax
--   
--   data Bar a = Bar1 a (Bar a) | Bar2 String
--     deriving Lift
--   </pre>
--   
--   Levity-polymorphic since <i>template-haskell-2.16.0.0</i>.
class Lift (t :: TYPE r)

-- | Turn a value into a Template Haskell expression, suitable for use in a
--   splice.
lift :: (Lift t, Quote m) => t -> m Exp

-- | Turn a value into a Template Haskell typed expression, suitable for
--   use in a typed splice.
liftTyped :: forall (m :: Type -> Type). (Lift t, Quote m) => t -> Code m t
data Q a
data Code (m :: Type -> Type) (a :: TYPE r)

-- | The <a>Quote</a> class implements the minimal interface which is
--   necessary for desugaring quotations.
--   
--   <ul>
--   <li>The <tt>Monad m</tt> superclass is needed to stitch together the
--   different AST fragments.</li>
--   <li><a>newName</a> is used when desugaring binding structures such as
--   lambdas to generate fresh names.</li>
--   </ul>
--   
--   Therefore the type of an untyped quotation in GHC is `Quote m =&gt; 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
--   <a>Exp</a> to be extracted purely from the quotation without
--   interacting with <a>Q</a>.
class Monad m => Quote (m :: Type -> Type)
data Exp

-- | Convert an implementation of <a>lift</a> into one for
--   <a>liftTyped</a>.
defaultLiftTyped :: (Lift a, Quote m) => a -> Code m a

-- | A compatibility shim for lifting an <tt>Addr#</tt> value.
liftAddrCompat :: Quote m => ForeignPtr Word8 -> Word -> Word -> m Exp

-- | A compatibility shim for lifting an <a>Int</a> value without
--   triggering bugs if <tt>RebindableSyntax</tt> is used in a module.
liftIntCompat :: Quote m => Integer -> m Exp
