[GHC] #9641: Point-free do block gives missing instance error

#9641: Point-free do block gives missing instance error -------------------------------------+------------------------------------- Reporter: rasfar | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Documentation | Version: 7.8.1 Keywords: plugins | Operating System: Linux HasDynFlags | Type of failure: Architecture: x86 | Documentation bug Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- https://www.haskell.org/ghc/docs/latest/html/users_guide/compiler- plugins.html#manipulating-bindings This API example won't compile for me. {{{#!hs module SayNames.Plugin (plugin) where import GhcPlugins plugin :: Plugin plugin = defaultPlugin { installCoreToDos = install } install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] install _ todo = do reinitializeGlobals return (CoreDoPluginPass "Say name" pass : todo) pass :: ModGuts -> CoreM ModGuts pass = do dflags <- getDynFlags bindsOnlyPass (mapM (printBind dflags)) where printBind :: DynFlags -> CoreBind -> CoreM CoreBind printBind dflags bndr@(NonRec b _) = do putMsgS $ "Non-recursive binding named " ++ showSDoc dflags (ppr b) return bndr printBind _ bndr = return bndr }}} Compiling (GHC 7.8.1, or 7.6.3). I get: {{{ SayNames/Plugin.hs:25:21: No instance for (HasDynFlags ((->) ModGuts)) arising from a use of ‘getDynFlags’ In a stmt of a 'do' block: dflags <- getDynFlags In the expression: do { dflags <- getDynFlags; bindsOnlyPass (mapM (printBind dflags)) } In an equation for ‘pass’: pass = do { dflags <- getDynFlags; bindsOnlyPass (mapM (printBind dflags)) } where printBind :: DynFlags -> CoreBind -> CoreM CoreBind printBind dflags bndr@(NonRec b _) = do { putMsgS $ "Non-recursive binding named " ++ showSDoc dflags (ppr b); .... } printBind _ bndr = return bndr }}} Changing to pointful style it compiles and works: {{{#!hs pass modguts = do dflags <- getDynFlags bindsOnlyPass (mapM (printBind dflags)) modguts }}} Maybe this is a compiler bug, actually? Dunno, I never use point-free style with monadic functions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9641 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9641: Point-free do block gives missing instance error -------------------------------------+------------------------------------- Reporter: rasfar | Owner: rwbarton Type: bug | Status: new Priority: normal | Milestone: Component: | Version: 7.8.1 Documentation | Keywords: plugins Resolution: | HasDynFlags Operating System: Linux | Architecture: x86 Type of failure: | Difficulty: Unknown Documentation bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by rwbarton): * owner: => rwbarton Comment: Thanks for the report. Yes, it is a documentation bug, just a mixup when the example was updated for 7.6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9641#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9641: Point-free do block gives missing instance error
-------------------------------------+-------------------------------------
Reporter: rasfar | Owner: rwbarton
Type: bug | Status: new
Priority: normal | Milestone:
Component: | Version: 7.8.1
Documentation | Keywords: plugins
Resolution: | HasDynFlags
Operating System: Linux | Architecture: x86
Type of failure: | Difficulty: Unknown
Documentation bug | Blocked By:
Test Case: | Related Tickets:
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by Reid Barton

#9641: Point-free do block gives missing instance error -------------------------------------+------------------------------------- Reporter: rasfar | Owner: rwbarton Type: bug | Status: closed Priority: normal | Milestone: Component: | Version: 7.8.1 Documentation | Keywords: plugins Resolution: fixed | HasDynFlags Operating System: Linux | Architecture: x86 Type of failure: | Difficulty: Unknown Documentation bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9641#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9641: Point-free do block gives missing instance error -------------------------------------+------------------------------------- Reporter: rasfar | Owner: rwbarton Type: bug | Status: closed Priority: normal | Milestone: Component: | Version: 7.8.1 Documentation | Keywords: plugins Resolution: fixed | HasDynFlags Operating System: Linux | Architecture: x86 Type of failure: | Difficulty: Unknown Documentation bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by rasfar): I can't determine whether it's against etiquette to comment "Thanks!" here after it's closed, but since I already did, thanks... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9641#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC