summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/8.10.1-notes.rst6
-rw-r--r--docs/users_guide/glasgow_exts.rst32
2 files changed, 18 insertions, 20 deletions
diff --git a/docs/users_guide/8.10.1-notes.rst b/docs/users_guide/8.10.1-notes.rst
index 21a7f2b275..1c47a002d7 100644
--- a/docs/users_guide/8.10.1-notes.rst
+++ b/docs/users_guide/8.10.1-notes.rst
@@ -73,6 +73,12 @@ Runtime system
Template Haskell
~~~~~~~~~~~~~~~~
+- The ``Lift`` typeclass is now levity-polymorphic and has a ``liftTyped``
+ method. Previously disallowed instances for unboxed tuples, unboxed sums, an
+ primitive unboxed types have also been added. Finally, the code generated by
+ :ghc-flags:`-XDeriveLift` has been simplified to take advantage of expression
+ quotations.
+
``ghc-prim`` library
~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst
index 1c1d4cbb85..781a10691e 100644
--- a/docs/users_guide/glasgow_exts.rst
+++ b/docs/users_guide/glasgow_exts.rst
@@ -4531,7 +4531,8 @@ Deriving ``Lift`` instances
The class ``Lift``, unlike other derivable classes, lives in
``template-haskell`` instead of ``base``. Having a data type be an instance of
``Lift`` permits its values to be promoted to Template Haskell expressions (of
-type ``ExpQ``), which can then be spliced into Haskell source code.
+type ``ExpQ`` and ``TExpQ a``), which can then be spliced into Haskell source
+code.
Here is an example of how one can derive ``Lift``:
@@ -4546,17 +4547,11 @@ Here is an example of how one can derive ``Lift``:
{-
instance (Lift a) => Lift (Foo a) where
- lift (Foo a)
- = appE
- (conE
- (mkNameG_d "package-name" "Bar" "Foo"))
- (lift a)
- lift (u :^: v)
- = infixApp
- (lift u)
- (conE
- (mkNameG_d "package-name" "Bar" ":^:"))
- (lift v)
+ lift (Foo a) = [| Foo a |]
+ lift ((:^:) u v) = [| (:^:) u v |]
+
+ liftTyped (Foo a) = [|| Foo a ||]
+ liftTyped ((:^:) u v) = [|| (:^:) u v ||]
-}
-----
@@ -4572,8 +4567,9 @@ Here is an example of how one can derive ``Lift``:
fooExp :: Lift a => Foo a -> Q Exp
fooExp f = [| f |]
-:extension:`DeriveLift` also works for certain unboxed types (``Addr#``, ``Char#``,
-``Double#``, ``Float#``, ``Int#``, and ``Word#``):
+Note that the ``Lift`` typeclass takes advantage of :ref:`runtime-rep` in order
+to support instances involving unboxed types. This means :extension:`DeriveLift`
+also works for these types:
::
@@ -4587,12 +4583,8 @@ Here is an example of how one can derive ``Lift``:
{-
instance Lift IntHash where
- lift (IntHash i)
- = appE
- (conE
- (mkNameG_d "package-name" "Unboxed" "IntHash"))
- (litE
- (intPrimL (toInteger (I# i))))
+ lift (IntHash i) = [| IntHash i |]
+ liftTyped (IntHash i) = [|| IntHash i ||]
-}