[commit: packages/template-haskell] wip/th-new: Add a method to the Quasi type class that adds new top-level declarations. (5be0fe8)

git at git.haskell.org git at git.haskell.org
Mon Sep 23 07:59:30 CEST 2013


Repository : ssh://git@git.haskell.org/template-haskell

On branch  : wip/th-new
Link       : http://git.haskell.org/packages/template-haskell.git/commitdiff/5be0fe8dd09c71ca9262669caaae5038cfd56e4c

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

commit 5be0fe8dd09c71ca9262669caaae5038cfd56e4c
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.


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

5be0fe8dd09c71ca9262669caaae5038cfd56e4c
 Language/Haskell/TH/Syntax.hs |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Language/Haskell/TH/Syntax.hs b/Language/Haskell/TH/Syntax.hs
index b62b7d9..9d15f5f 100644
--- a/Language/Haskell/TH/Syntax.hs
+++ b/Language/Haskell/TH/Syntax.hs
@@ -62,6 +62,8 @@ class (Monad m, Applicative m) => Quasi m where
 
   qAddDependentFile :: FilePath -> m ()
 
+  qAddTopDecls :: [Dec] -> m ()
+
 -----------------------------------------------------
 --	The IO instance of Quasi
 --
@@ -88,6 +90,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
 
@@ -330,6 +333,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
@@ -341,6 +349,7 @@ instance Quasi Q where
   qLocation 	    = location
   qRunIO    	    = runIO
   qAddDependentFile = addDependentFile
+  qAddTopDecls      = addTopDecls
 
 
 ----------------------------------------------------




More information about the ghc-commits mailing list