[commit: template-haskell] th-new: Make a TExp a wrap a TH.Exp instead of a TH.ExpQ. (55d3503)

Geoffrey Mainland gmainlan at microsoft.com
Wed May 22 11:05:17 CEST 2013


Repository : ssh://darcs.haskell.org//srv/darcs/packages/template-haskell

On branch  : th-new

http://hackage.haskell.org/trac/ghc/changeset/55d35031ce156ebbb117982dd17c09a8c73b9714

>---------------------------------------------------------------

commit 55d35031ce156ebbb117982dd17c09a8c73b9714
Author: Geoffrey Mainland <mainland at apeiron.net>
Date:   Tue May 21 15:10:35 2013 +0100

    Make a TExp a wrap a TH.Exp instead of a TH.ExpQ.
    
    We also provide two new helper functions:
    
      unTypeQ :: Q (TExp a) -> Q Exp
    
      unsafeTExpCoerce :: Q Exp -> Q (TExp a)

>---------------------------------------------------------------

 Language/Haskell/TH/Syntax.hs |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/Language/Haskell/TH/Syntax.hs b/Language/Haskell/TH/Syntax.hs
index c791ad5..5e967f6 100644
--- a/Language/Haskell/TH/Syntax.hs
+++ b/Language/Haskell/TH/Syntax.hs
@@ -150,7 +150,15 @@ instance Applicative Q where
 --
 -----------------------------------------------------
 
-newtype TExp a = TExp { unType :: Q Exp }
+newtype TExp a = TExp { unType :: Exp }
+
+unTypeQ :: Q (TExp a) -> Q Exp
+unTypeQ m = do { TExp e <- m
+               ; return e }
+
+unsafeTExpCoerce :: Q Exp -> Q (TExp a)
+unsafeTExpCoerce m = do { e <- m
+                        ; return (TExp e) }
 
 ----------------------------------------------------
 -- Packaged versions for the programmer, hiding the Quasi-ness





More information about the ghc-commits mailing list