diff options
author | Jan Stolarek <jan.stolarek@p.lodz.pl> | 2015-09-08 19:19:44 +0200 |
---|---|---|
committer | Jan Stolarek <jan.stolarek@p.lodz.pl> | 2015-10-16 20:15:44 +0200 |
commit | 75492e7467ff962f2f2e29e5c8b2c588c94ae8a7 (patch) | |
tree | 8ed0f57f12dbb5c73b0f0d1d1994aef5dd89cea0 /docs | |
parent | b1884b0e62f62e3c0859515c4137124ab0c9560e (diff) | |
download | haskell-75492e7467ff962f2f2e29e5c8b2c588c94ae8a7.tar.gz |
Add typed holes support in Template Haskell.
Fixes #10267. Typed holes in typed Template Haskell currently don't work.
See #10945 and #10946.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/7.12.1-notes.rst | 4 | ||||
-rw-r--r-- | docs/users_guide/glasgow_exts.rst | 42 |
2 files changed, 18 insertions, 28 deletions
diff --git a/docs/users_guide/7.12.1-notes.rst b/docs/users_guide/7.12.1-notes.rst index 14b0beff75..05ab2e2e6d 100644 --- a/docs/users_guide/7.12.1-notes.rst +++ b/docs/users_guide/7.12.1-notes.rst @@ -128,6 +128,10 @@ Template Haskell - Partial type signatures can now be used in splices, see :ref:`pts-where`. +- ``Template Haskell`` now fully supports typed holes and quoting unbound + variables. This means it is now possible to use pattern splices nested + inside quotation brackets. + - ``Template Haskell`` now supports the use of ``UInfixT`` in types to resolve infix operator fixities, in the same vein as ``UInfixP`` and ``UInfixE`` in patterns and expressions. ``ParensT`` and ``InfixT`` diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 0ad41cf270..5f7a4dc9b8 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -9349,42 +9349,28 @@ on. This abbreviation makes top-level declaration slices quieter and less intimidating. -- Outermost pattern splices may bind variables. By "outermost" here, we - refer to a pattern splice that occurs outside of any quotation - brackets. For example, +- Pattern splices introduce variable binders but scoping of variables in + expressions inside the pattern's scope is only checked when a splice is + run. Note that pattern splices that occur outside of any quotation + brackets are run at compile time. Pattern splices occurring inside a + quotation bracket are *not* run at compile time; they are run when the + bracket is spliced in, sometime later. For example, :: - mkPat :: Bool -> Q Pat - mkPat True = [p| (x, y) |] - mkPat False = [p| (y, x) |] + mkPat :: Q Pat + mkPat = [p| (x, y) |] -- in another module: foo :: (Char, String) -> String - foo $(mkPat True) = x : y + foo $(mkPat) = x : z - bar :: (String, Char) -> String - bar $(mkPat False) = x : y + bar :: Q Exp + bar = [| \ $(mkPat) -> x : w |] -- Nested pattern splices do *not* bind variables. By "nested" here, we - refer to a pattern splice occurring within a quotation bracket. - Continuing the example from the last bullet: - - :: - - baz :: Bool -> Q Exp - baz b = [| quux $(mkPat b) = x + y |] - - would fail with ``x`` and ``y`` being out of scope. - - The difference in treatment of outermost and nested pattern splices - is because outermost splices are run at compile time. GHC can then - use the result of running the splice when analysing the expressions - within the pattern's scope. Nested splices, on the other hand, are - *not* run at compile time; they are run when the bracket is spliced - in, sometime later. Since nested pattern splices may refer to local - variables, there is no way for GHC to know, at splice compile time, - what variables are bound, so it binds none. + will fail with ``z`` being out of scope in the definition of ``foo`` but it + will *not* fail with ``w`` being out of scope in the definition of ``bar``. + That will only happen when ``bar`` is spliced. - A pattern quasiquoter *may* generate binders that scope over the right-hand side of a definition because these binders are in scope |