[commit: template-haskell] th-new-7.6: Add a method to the Quasi type class that adds new top-level declarations. (89799a0)

Geoffrey Mainland gmainlan at microsoft.com
Wed Jun 12 12:04:22 CEST 2013


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

On branch  : th-new-7.6

http://hackage.haskell.org/trac/ghc/changeset/89799a0907c8cb3388387836ef64753b50d4e1bc

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

commit 89799a0907c8cb3388387836ef64753b50d4e1bc
Author: Geoffrey Mainland <mainland at apeiron.net>
Date:   Tue May 21 13:39:44 2013 +0100

    Add a method to the Quasi type class that adds new top-level declarations.

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

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

diff --git a/Language/Haskell/TH/Syntax.hs b/Language/Haskell/TH/Syntax.hs
index a1a4ec3..4a0aeae 100644
--- a/Language/Haskell/TH/Syntax.hs
+++ b/Language/Haskell/TH/Syntax.hs
@@ -68,6 +68,8 @@ class (Monad m, Applicative m) => Quasi m where
 
   qAddDependentFile :: FilePath -> m ()
 
+  qAddTopDecls :: [Dec] -> m ()
+
 -----------------------------------------------------
 --	The IO instance of Quasi
 -- 
@@ -93,6 +95,7 @@ instance Quasi IO where
   qLocation    	      = badIO "currentLocation"
   qRecover _ _ 	      = badIO "recover" -- Maybe we could fix this?
   qAddDependentFile _ = badIO "addDependentFile"
+  qAddTopDecls _      = badIO "addTopDecls"
 
   qRunIO m = m
   
@@ -328,6 +331,11 @@ runIO m = Q (qRunIO m)
 addDependentFile :: FilePath -> Q ()
 addDependentFile fp = Q (qAddDependentFile fp)
 
+-- | Add additional top-level declarations. The added declarations will be type
+-- checked along with the current declaration group.
+addTopDecls :: [Dec] -> Q ()
+addTopDecls ds = Q (qAddTopDecls ds)
+
 instance Quasi Q where
   qNewName  	    = newName
   qReport   	    = report
@@ -338,6 +346,7 @@ instance Quasi Q where
   qLocation 	    = location
   qRunIO    	    = runIO
   qAddDependentFile = addDependentFile
+  qAddTopDecls      = addTopDecls
 
 
 ----------------------------------------------------





More information about the ghc-commits mailing list