[commit: ghc] master: Fix/update SayAnnNames plugin example code. (71aaa3f)

Erik de Castro erikd at mega-nerd.com
Sat May 4 21:27:47 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/71aaa3f2aec288ab05fd60cce73b9633a015ab6b

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

commit 71aaa3f2aec288ab05fd60cce73b9633a015ab6b
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date:   Sun May 5 04:34:38 2013 +1000

    Fix/update SayAnnNames plugin example code.

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

 docs/users_guide/extending_ghc.xml | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/docs/users_guide/extending_ghc.xml b/docs/users_guide/extending_ghc.xml
index 1abe8a8..dc8d5b4 100644
--- a/docs/users_guide/extending_ghc.xml
+++ b/docs/users_guide/extending_ghc.xml
@@ -247,9 +247,8 @@ pass = do dflags &lt;- getDynFlags
 {-# LANGUAGE DeriveDataTypeable #-}
 module SayAnnNames.Plugin (plugin, SomeAnn) where
 import GhcPlugins
-import Control.Monad (when)
+import Control.Monad (unless)
 import Data.Data
-import Data.Typeable
 
 data SomeAnn = SomeAnn deriving (Data, Typeable)
 
@@ -264,13 +263,15 @@ install _ todo = do
   return (CoreDoPluginPass "Say name" pass : todo)
 
 pass :: ModGuts -> CoreM ModGuts
-pass g = mapM_ (printAnn g) (mg_binds g) >> return g
-  where printAnn :: ModGuts -> CoreBind -> CoreM CoreBind
-        printAnn guts bndr@(NonRec b _) = do
+pass g = do
+          dflags &lt;- getDynFlags
+          mapM_ (printAnn dflags g) (mg_binds g) >> return g
+  where printAnn :: DynFlags -> ModGuts -> CoreBind -> CoreM CoreBind
+        printAnn dflags guts bndr@(NonRec b _) = do
           anns &lt;- annotationsOn guts b :: CoreM [SomeAnn]
-          when (not $ null anns) $ putMsgS $ "Annotated binding found: " ++  showSDoc (ppr b)
+          unless (null anns) $ putMsgS $ "Annotated binding found: " ++  showSDoc dflags (ppr b)
           return bndr
-        printAnn _ bndr = return bndr
+        printAnn _ _ bndr = return bndr
 
 annotationsOn :: Data a => ModGuts -> CoreBndr -> CoreM [a]
 annotationsOn guts bndr = do





More information about the ghc-commits mailing list