[GHC] #5941: Add compilation stage plugins

GHC ghc-devs at haskell.org
Fri Nov 28 18:24:00 UTC 2014


#5941: Add compilation stage plugins
-------------------------------------+-------------------------------------
              Reporter:  tibbe       |            Owner:
                  Type:  feature     |           Status:  infoneeded
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:  7.4.1
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by rodlogic):

 Now, from a user of this feature (or such feature), I would like to be
 able to do the following.

 Assuming I have, for example, two modules:
 {{{#!hs
 module A where

 import B

 main = sayHello "Joe"
 }}}

 {{{#!hs
 module B where

 sayHello :: String -> IO ()
 sayHello = putStrLn
 }}}

 I would like to create a plugin, here named {{{DependenciesPlugin}}}, that
 is invoked with:
 {{{#!sh
 ghc -fplugin=DependenciesPlugin --make A.hs
 }}}

 This plugin would be called once to initialize itself, which in this case
 means creating a {{{A.dot}}} file:
 {{{
 graph ModuleADependencies {
 }}}

 And once to terminate itself so that the {{{A.dot}}} file can be closed:
 {{{
 }
 }}}

 In between the initialization and termination, the plugin would be called
 for each module to process the TypecheckedModule and generate a subgraph
 and the function dependencies:

 {{{
   subgraph ModuleA {
      ModuleA.main [label="main"]
   }
   ModuleA.main -> ModuleB.sayHello

   subgraph ModuleB {
      ModuleB.sayHello [label="sayHello"]
   }
 }}}

 And command line options could be provided to tailor the DOT file
 generation (just module dependencies, only function dependencies, both,
 only dependencies from a specific functions, etc). Another option is to
 also take into account the packages these modules come from.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/5941#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list