#7682 closed bug (fixed)

Plugin example not updated for ghc 7.6

Reported by: edsko Owned by:
Priority: normal Milestone:
Component: Documentation Version: 7.6.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The GHC plugin docs (http://www.haskell.org/ghc/docs/latest/html/users_guide/compiler-plugins.html) have this example:

pass :: ModGuts -> CoreM ModGuts
pass = bindsOnlyPass (mapM printBind)
  where printBind :: CoreBind -> CoreM CoreBind
        printBind bndr@(NonRec b _) = do
          putMsgS $ "Non-recursive binding named " ++ showSDoc (ppr b)
          return bndr 
        printBind bndr = return bndr

but in ghc >= 7.6 showSDoc requires DynFlags:

pass :: ModGuts -> CoreM ModGuts
pass guts = do
    dynFlags <- getDynFlags
    bindsOnlyPass (mapM $ printBind dynFlags) guts
  where 
    printBind :: DynFlags -> CoreBind -> CoreM CoreBind
    printBind _dynFlags bndr@(NonRec b _) = do
#if __GLASGOW_HASKELL__ >= 706
      putMsgS $ "Non-recursive binding named " ++ showSDoc _dynFlags (ppr b)
#else
      putMsgS $ "Non-recursive binding named " ++ showSDoc (ppr b)
#endif
      return bndr 
    printBind _dynFlags bndr = return bndr

Change History (2)

comment:1 Changed 14 months ago by ian@…

commit cb34ce9dabb263c515e914461e65afdb258ae396

Author: Ian Lynagh <ian@well-typed.com>
Date:   Sun Feb 24 16:20:04 2013 +0000

    Fix the compiler plugin example; patch from edsko; fixes #7682

 docs/users_guide/extending_ghc.xml |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

comment:2 Changed 14 months ago by igloo

  • Difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from new to closed

Fixed, thanks

Note: See TracTickets for help on using tickets.