diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2013-05-05 04:34:38 +1000 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2013-05-05 05:07:45 +1000 |
commit | 71aaa3f2aec288ab05fd60cce73b9633a015ab6b (patch) | |
tree | 29ab6ef4bab90c9c14da305c2157dc5bf4b20376 /docs/users_guide | |
parent | ed54858977e98a833a5767a9c2d07b05c20e5aff (diff) | |
download | haskell-71aaa3f2aec288ab05fd60cce73b9633a015ab6b.tar.gz |
Fix/update SayAnnNames plugin example code.
Diffstat (limited to 'docs/users_guide')
-rw-r--r-- | docs/users_guide/extending_ghc.xml | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/docs/users_guide/extending_ghc.xml b/docs/users_guide/extending_ghc.xml index 1abe8a8f68..dc8d5b4739 100644 --- a/docs/users_guide/extending_ghc.xml +++ b/docs/users_guide/extending_ghc.xml @@ -247,9 +247,8 @@ pass = do dflags <- 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 <- 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 <- 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 |