HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleth-lift-0.8.6Haskell2010

Language.Haskell.TH.Lift

  • 1 class
  • 6 values
  • Packageth-lift-0.8.6
  • Exports7
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceLift.hs
valuederiveLift' :: [Role] -> Info -> Q [Dec]
#

Obtain Info values through a custom reification function. This is useful when generating instances for datatypes that have not yet been declared.

valuemakeLift :: Name -> Q Exp
#

Generates a lambda expresson which behaves like lift (without requiring a Lift instance). Example:

newtype Fix f = In { out :: f (Fix f) }

instance Lift (f (Fix f)) => Lift (Fix f) where
  lift = $(makeLift ''Fix)

This can be useful when deriveLift is not clever enough to infer the correct instance context, such as in the example above.

classclass Lift (t :: TYPE r) where
#

A Lift 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 ([| ... |] or [|| ... ||]) but not at the top level. As an example:

add1 :: Int -> Code Q Int
add1 x = [|| x + 1 ||]

Template Haskell has no way of knowing what value x will take on at splice-time, so it requires the type of x to be an instance of Lift.

A Lift instance must satisfy $(lift x) ≡ x and $$(liftTyped x) ≡ x for all x, where $(...) and $$(...) are Template Haskell splices. It is additionally expected that lift x ≡ unTypeCode (liftTyped x).

Lift instances can be derived automatically by use of the -XDeriveLift GHC language extension:

{-# LANGUAGE DeriveLift #-}
module Foo where

import Language.Haskell.TH.Syntax

data Bar a = Bar1 a (Bar a) | Bar2 String
  deriving Lift

Representation-polymorphic since template-haskell-2.16.0.0.

Methods

  • lift :: Quote m => t -> m Exp

    Turn a value into a Template Haskell expression, suitable for use in a splice.

  • liftTyped :: Quote m => t -> Code m t

    Turn a value into a Template Haskell typed expression, suitable for use in a typed splice.

Instances69Lift, …
  • Lift ByteArrayDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Lift IntegerDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift NaturalDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift VoidDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Int16Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Int32Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Int64Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Int8Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Word16Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Word32Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Word64Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Word8Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Addr#Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax

    Produces an Addr# literal from the NUL-terminated C-string starting at the given memory address.

  • Lift Char#Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Double#Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Float#Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Int#Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift Word#Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift BoolDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift CharDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift DoubleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift FloatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift IntDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift WordDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift ModNameDefined in th-lift-0.8.6 · Language.Haskell.TH.Lift · orphan
  • Lift NameDefined in th-lift-0.8.6 · Language.Haskell.TH.Lift · orphan
  • Lift NameFlavourDefined in th-lift-0.8.6 · Language.Haskell.TH.Lift · orphan
  • Lift NameSpaceDefined in th-lift-0.8.6 · Language.Haskell.TH.Lift · orphan
  • Lift OccNameDefined in th-lift-0.8.6 · Language.Haskell.TH.Lift · orphan
  • Lift PkgNameDefined in th-lift-0.8.6 · Language.Haskell.TH.Lift · orphan
  • Lift ()Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift (# #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Integral a => Lift (Ratio a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift a => Lift (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • Lift a => Lift (Digit a)Defined in containers-0.7 · Data.Sequence.Internal
  • Lift a => Lift (FingerTree a)Defined in containers-0.7 · Data.Sequence.Internal
  • Lift a => Lift (Node a)Defined in containers-0.7 · Data.Sequence.Internal
  • Lift a => Lift (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Lift a => Lift (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Lift a => Lift (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Lift a => Lift (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Lift a => Lift (Tree a)Defined in containers-0.7 · Data.Tree
  • Lift a => Lift (NonEmpty a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift a => Lift (Maybe a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift a => Lift [a]Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift vertex => Lift (SCC vertex)Defined in containers-0.7 · Data.Graph
  • Lift (Fixed a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b) => Lift (Either a b)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b) => Lift (a, b)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift k, Lift a) => Lift (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • (Lift a, Lift b, Lift c) => Lift (a, b, c)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d) => Lift (a, b, c, d)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e) => Lift (a, b, c, d, e)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) => Lift (a, b, c, d, e, f)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) => Lift (a, b, c, d, e, f, g)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Lift a => Lift (# a #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b) => Lift (# a, b #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b) => Lift (# a | b #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c) => Lift (# a, b, c #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c) => Lift (# a | b | c #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d) => Lift (# a, b, c, d #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d) => Lift (# a | b | c | d #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e) => Lift (# a, b, c, d, e #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e) => Lift (# a | b | c | d | e #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) => Lift (# a, b, c, d, e, f #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) => Lift (# a | b | c | d | e | f #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) => Lift (# a, b, c, d, e, f, g #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) => Lift (# a | b | c | d | e | f | g #)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax

Orphan instances

6 instances