th-lift-0.8.2: Derive Template Haskell's Lift class for datatypes.

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.TH.Lift

Contents

Synopsis

Documentation

deriveLiftMany :: [Name] -> Q [Dec] Source #

Derive Lift instances for many datatypes.

deriveLift' :: [Role] -> Info -> Q [Dec] Source #

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

makeLift :: Name -> Q Exp Source #

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.

makeLift' :: Info -> Q Exp Source #

Like makeLift, but using a custom reification function.

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

add1 :: Int -> Q Exp
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 for all x, where $(...) is a Template Haskell splice.

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

Minimal complete definition

Nothing

Methods

lift :: t -> Q Exp #

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

Instances
Lift Bool 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Bool -> Q Exp #

Lift Char 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Char -> Q Exp #

Lift Double 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Double -> Q Exp #

Lift Float 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Float -> Q Exp #

Lift Int 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Int -> Q Exp #

Lift Int8 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Int8 -> Q Exp #

Lift Int16 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Int16 -> Q Exp #

Lift Int32 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Int32 -> Q Exp #

Lift Int64 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Int64 -> Q Exp #

Lift Integer 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Integer -> Q Exp #

Lift Natural 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Natural -> Q Exp #

Lift Word 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Word -> Q Exp #

Lift Word8 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Word8 -> Q Exp #

Lift Word16 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Word16 -> Q Exp #

Lift Word32 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Word32 -> Q Exp #

Lift Word64 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Word64 -> Q Exp #

Lift Name Source # 
Instance details

Defined in Language.Haskell.TH.Lift

Methods

lift :: Name -> Q Exp #

Lift () 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: () -> Q Exp #

Lift ModName Source # 
Instance details

Defined in Language.Haskell.TH.Lift

Methods

lift :: ModName -> Q Exp #

Lift PkgName Source # 
Instance details

Defined in Language.Haskell.TH.Lift

Methods

lift :: PkgName -> Q Exp #

Lift OccName Source # 
Instance details

Defined in Language.Haskell.TH.Lift

Methods

lift :: OccName -> Q Exp #

Lift NameFlavour Source # 
Instance details

Defined in Language.Haskell.TH.Lift

Methods

lift :: NameFlavour -> Q Exp #

Lift NameSpace Source # 
Instance details

Defined in Language.Haskell.TH.Lift

Methods

lift :: NameSpace -> Q Exp #

Lift a => Lift [a] 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: [a] -> Q Exp #

Lift a => Lift (Maybe a) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Maybe a -> Q Exp #

Integral a => Lift (Ratio a) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Ratio a -> Q Exp #

(Lift a, Lift b) => Lift (Either a b) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Either a b -> Q Exp #

(Lift a, Lift b) => Lift (a, b) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: (a, b) -> Q Exp #

(Lift a, Lift b, Lift c) => Lift (a, b, c) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: (a, b, c) -> Q Exp #

(Lift a, Lift b, Lift c, Lift d) => Lift (a, b, c, d) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: (a, b, c, d) -> Q Exp #

(Lift a, Lift b, Lift c, Lift d, Lift e) => Lift (a, b, c, d, e) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: (a, b, c, d, e) -> Q Exp #

(Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) => Lift (a, b, c, d, e, f) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: (a, b, c, d, e, f) -> Q Exp #

(Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) => Lift (a, b, c, d, e, f, g) 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: (a, b, c, d, e, f, g) -> Q Exp #

Orphan instances

Lift Name Source # 
Instance details

Methods

lift :: Name -> Q Exp #

Lift ModName Source # 
Instance details

Methods

lift :: ModName -> Q Exp #

Lift PkgName Source # 
Instance details

Methods

lift :: PkgName -> Q Exp #

Lift OccName Source # 
Instance details

Methods

lift :: OccName -> Q Exp #

Lift NameFlavour Source # 
Instance details

Methods

lift :: NameFlavour -> Q Exp #

Lift NameSpace Source # 
Instance details

Methods

lift :: NameSpace -> Q Exp #